微风及;OData:扩展集合时遇到问题 工作原理:

微风及;OData:扩展集合时遇到问题 工作原理:,odata,breeze,jaydata,Odata,Breeze,Jaydata,在Breeze中,我可以执行以下查询: Q1 breeze.EntityQuery.from('accounts').where('id', 'eq', account_id) http://localhost:8000/odata/findash.svc/accounts ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx' http://localhost:8000/odata/findash.svc/ accounts('N

在Breeze中,我可以执行以下查询:

Q1

breeze.EntityQuery.from('accounts').where('id', 'eq', account_id)
http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'
http://localhost:8000/odata/findash.svc/
    accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions
导致此请求的原因:

R1

breeze.EntityQuery.from('accounts').where('id', 'eq', account_id)
http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'
http://localhost:8000/odata/findash.svc/
    accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions
返回正确的数据,但事务属性如下所示:

transactions: {
    __deferred: {
        uri: "http://localhost:8000/odata/findash.svc/accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions"
    }
}
我尝试在事务处点击URI。\uu deferred.URI在浏览器中

R1.1

breeze.EntityQuery.from('accounts').where('id', 'eq', account_id)
http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'
http://localhost:8000/odata/findash.svc/
    accounts('NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx')/transactions
而且它确实以我所期望的交易来回应

什么不起作用: 为了尝试通过Breeze获取该事务列表,我使用如下expand子句修改了上述查询:

Q2

breeze.EntityQuery.from('accounts')
    .where('id', 'eq', account_id).expand('transactions')
http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'&$expand=transactions
导致此请求的原因:

R2

breeze.EntityQuery.from('accounts')
    .where('id', 'eq', account_id).expand('transactions')
http://localhost:8000/odata/findash.svc/accounts
    ?$filter=id eq 'NTE5M2UxMzQzMmY3MDAxYzE1MDAwMDAx'&$expand=transactions
这会产生500个错误

我还尝试了以下问题:

Q3

breeze.EntityQuery.from('transactions')
    .expand('account').where('account.id', 'eq', account_id)
这也会产生500个错误

我需要知道的是: 在深入研究基于Node+MongoDB+JayData的OData服务之前,我试图排除Breeze

上面R1和R2之间的唯一区别是添加了
和$expand=transactions
。R1工作,R2产生500错误。如果R2是一个有效的OData请求,那么我需要将故障排除工作集中在JayData实现上。对我来说,问题是我对Breeze、OData和JayData都是新手,所以我很难缩小搜索范围

作为参考,我的JayData context.js如下:

$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;
$data.Class.define(“$findash.Types.Account”,$data.Entity,null{
id:{type:“id”,key:true,computed:true},
名称:{type:“string”},
状态:{type:“string”},
注:{type:“string”},
事务:{type:“Array”,elementType:$findash.Types.Transaction,inverseProperty:“account”}
},空);
$data.Class.define(“$findash.Types.Transaction”,$data.Entity,null{
id:{type:“id”,key:true,computed:true},
帐户:{type:$findash.Types.account],inverseProperty:“transactions”},
收款人:{type:“string”},
备注:{type:“string”},
金额:{type:“int”}
},空);
$data.Class.define(“$findash.Types.FinanceContext”,$data.EntityContext,null{
帐户:{type:$data.EntitySet,elementType:$findash.Types.Account},
事务:{type:$data.EntitySet,elementType:$findash.Types.Transaction}
},空);
$findash.Types.FinanceContext.generateTestData=函数(上下文,回调){
context.accounts.add(新的$findash.Types.Account({
名称:'正在检查',
状态:“活动”,
注:“注意到lorem ipsum Door sit amet,奉献精英。Vivamus mauris quam,Tincident id元素,mollis eget urna。未发酵液是威尼斯的马来酸盐。在nisl malesuada dictum nec libero征服了ipsum。

奉献精神,在luctus ipsum metus,在feugiat,在purus lacus semper nibh,在luctus ipsum metus不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平。不公平, 交易:[ 新$findash.Types.Transaction({ 收款人:'壳牌天然气', 备注:“支票卡交易”, 金额:-3500 }), 新$findash.Types.Transaction({ 收款人:'克罗格', 备注:“支票卡交易”, 金额:-9000 }), 新$findash.Types.Transaction({ 收款人:“爸爸墨菲的”, 备注:“支票卡交易”, 金额:-1500 }) ] })); context.accounts.add(新的$findash.Types.Account({ 姓名:“储蓄” })); context.accounts.add(新的$findash.Types.Account({ 名称:“电力公司” })); context.accounts.add(新的$findash.Types.Account({ 名称:“天然气公司” })); context.accounts.add(新的$findash.Types.Account({ 名称:“有线电视公司” })); context.accounts.add(新的$findash.Types.Account({ 名称:‘水务公司’ })); context.accounts.add(新的$findash.Types.Account({ 名称:“垃圾箱服务” })); context.saveChanges(函数(计数){ 如果(回调){ 回调(计数); } }); }; module.exports=exports=$findash.Types.FinanceContext;
您可以发布服务器端模型相关部分的代码吗?这看起来像是服务器端模型定义的问题,或者是如何通过OData公开模型定义的问题


这方面的真正考验是尝试在完全没有微风的情况下使用OData服务。我猜你也会犯同样的错误。如果不是,则这是一个错误。如果是这样,那么您需要检查OData服务

你试过没有微风的OData电话吗?你确定JayData支持OData“扩展”吗?嗨,我来自Jaydatak,JayData的创建者。JayData服务器仅支持使用Pro mongodb驱动程序进行扩展。Pro驱动程序免费用于非商业用途,payware免费用于商业用途。它的价格为250美元,但提供了其他不错的功能,不仅导航,而且地理搜索,索引处理和包括专业支持。对不起,错误的信息!!expand也适用于免费版本,但必须使用最新版本(1.3)