0

What works:

In Breeze I can execute this query:

Q1

breeze.EntityQuery.from('accounts').where('id', 'eq', account_id)

which results in this request:

R1

http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'

which returns the correct data except that the transactions property looks like this:

transactions: {
    __deferred: {
        uri: "http://localhost:8000/odata/findash.svc/accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions"
    }
}

I tried hitting the URI at transactions.__deferred.uri in a browser

R1.1

http://localhost:8000/odata/findash.svc/
    accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions

and it does respond with the transactions I would expect.

What doesn't work:

To try and get that transaction list through Breeze I alter the above query with an expand clause like so:

Q2

breeze.EntityQuery.from('accounts')
    .where('id', 'eq', account_id).expand('transactions')

which results in this request:

R2

http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'&$expand=transactions

which generates a 500 error.

I also tried this Breeze query:

Q3

breeze.EntityQuery.from('transactions')
    .expand('account').where('account.id', 'eq', account_id)

which also generates a 500 error.

What I need to know:

I'm trying to rule out Breeze before I dive into the OData service which is built on Node+MongoDB+JayData.

The only difference between R1 and R2 above is the addition of &$expand=transactions. R1 works and R2 results in a 500 error. If R2 is a valid OData request then I need to focus my troubleshooting efforts on my JayData implimentation. The trouble for me is that I'm new to Breeze, OData & JayData, so I'm having trouble narrowing my search.

For reference, my JayData context.js is here:

$data.Class.define("$findash.Types.Account", $data.Entity, null, {
    id: { type: "id", key: true, computed: true },
    name: { type: "string" },
    status: { type: "string" },
    notes: { type: "string" },
    transactions: { type: "Array", elementType: "$findash.Types.Transaction", inverseProperty: "account" }
}, null);
$data.Class.define("$findash.Types.Transaction", $data.Entity, null, {
    id: { type: "id", key: true, computed: true },
    account: { type: "$findash.Types.Account", inverseProperty: "transactions" },
    payee: { type: "string" },
    memo: { type: "string" },
    amount: { type: "int" }
}, null);
$data.Class.define("$findash.Types.FinanceContext", $data.EntityContext, null, {
    accounts: { type: $data.EntitySet, elementType: $findash.Types.Account },
    transactions: { type: $data.EntitySet, elementType: $findash.Types.Transaction }
}, null);
$findash.Types.FinanceContext.generateTestData = function (context, callBack) {
    context.accounts.add(new $findash.Types.Account({
        name: 'Checking',
        status: 'Active',
        notes: '<p>Notes lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mauris quam, elementum in tincidunt id, mollis eget urna. Nulla fermentum est id risus venenatis malesuada. Quisque sed ipsum at nisl malesuada dictum vitae nec libero.</p><p>Aenean consectetur, purus eu semper feugiat, purus lacus semper nibh, at luctus ipsum metus non justo. Donec justo mi, rutrum a scelerisque sed, feugiat vel quam. Etiam justo nisi, vehicula ac congue vitae, ultricies non quam. Aliquam a velit in mauris luctus elementum. Praesent sollicitudin quam mattis velit sodales vitae feugiat felis volutpat.</p>',
        transactions: [
            new $findash.Types.Transaction({
                payee: 'Shell Gas',
                memo: 'Checkcard Transaction',
                amount: -3500
            }),
            new $findash.Types.Transaction({
                payee: 'Kroger',
                memo: 'Checkcard Transaction',
                amount: -9000
            }),
            new $findash.Types.Transaction({
                payee: 'Papa Murphy\'s',
                memo: 'Checkcard Transaction',
                amount: -1500
            })
        ]
    }));
    context.accounts.add(new $findash.Types.Account({
        name: 'Savings'
    }));
    context.accounts.add(new $findash.Types.Account({
        name: 'Power Company'
    }));
    context.accounts.add(new $findash.Types.Account({
        name: 'Gas Company'
    }));
    context.accounts.add(new $findash.Types.Account({
        name: 'Cable Company'
    }));
    context.accounts.add(new $findash.Types.Account({
        name: 'Water Company'
    }));
    context.accounts.add(new $findash.Types.Account({
        name: 'Trash Service'
    }));
    context.saveChanges(function (count) {
        if (callBack) {
            callBack(count);
        }
    });
};
module.exports = exports = $findash.Types.FinanceContext;

1 Answers1

0

Can you post the code for the relevant sections of the server side model? This looks like a problem on the server side with the model definition, or how it is exposed thru OData.

The real test of this is to try hitting the OData service without Breeze involved at all. I'm guessing that you will get the same error. If not, then this is a Breeze error. If so, then you need to review your OData service.

Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • Have you tried the OData call without Breeze? Are you sure that JayData supports OData "expand"? – Jay Traband May 16 '13 at 16:25
  • Hi, I'm from JayStack, creator of JayData. JayData Server supports expand with the Pro mongodb driver only. Pro drivers are free for non-commercial use and payware for commercial use. It costs 250 usd but provides other nice features, not only navigation but also geo search, index handling and includes professional support. – Gabor Dolla May 17 '13 at 06:19
  • sorry, wrong info!! expand works with the free version too, but you have to use the latest version (1.3) – Gabor Dolla May 17 '13 at 08:03