TypeError:Object[Object Array]没有方法'getProperty'
TypeError: Object [object Array] has no method 'getProperty'
我对这整个发布问题的事情有点陌生,所以请温柔一点!
我使用Breeze作为"Hot Towel"SPA堆栈的一部分,并从用PHP编写的自定义WebApi端点检索数据。这不是一个完整的实现,我只是写了足够的东西来满足我的需求。
我的端点正在生成的元数据如下:
{
"shortName": "Project",
"namespace": "WebApi.ORM.Cartesius",
"autoGeneratedKeyType": "Identity",
"defaultResourceName": "Project",
"dataProperties": [
{
"name": "id",
"isPartOfKey": true,
"isNullable": false,
"dataType": "Int32"
},
{
"name": "title",
"isNullable": false,
"maxLength": 256,
"dataType": "String"
},
{
"name": "date",
"isNullable": false,
"dataType": "DateTime"
},
{
"name": "review_date",
"isNullable": true,
"dataType": "DateTime"
},
{
"name": "summary",
"isNullable": true,
"dataType": "String"
}
],
"navigationProperties": [
{
"name": "Team",
"entityTypeName": "Team:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "team_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
{
"name": "ProjectAuthor",
"entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "project_author_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
{
"name": "Itinerary",
"entityTypeName": "Itinerary:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "itinerary_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
一切都很好,直到我尝试对我的查询进行扩展:
var query = new breeze.EntityQuery()
.from("Project")
.where("id","eq",project.id)
.expand("ProjectAuthor");
此查询从我的端点返回以下内容:
[
{
"$id": 1,
"$type": "WebApi.ORM.Cartesius.Project",
"id": 2,
"title": "teat",
"date": "2013-11-04 14:00:00+07",
"review_date": null,
"summary": null,
"ProjectAuthor": [
{
"$id": 2,
"$type": "WebApi.ORM.Cartesius.ProjectAuthor",
"id": 1,
"account_id": 1,
"project_id": 2,
"Project": [
{
"$ref": 1
}
]
},
{
"$id": 3,
"$type": "WebApi.ORM.Cartesius.ProjectAuthor",
"id": 3,
"account_id": 2,
"project_id": 2,
"Project": [
{
"$ref": 1
}
]
}
]
}
]
然后Breeze在投掷时窒息:
TypeError: Object [object Array] has no method 'getProperty'
调试指向Breeze中的第5059行,它试图在一个实体数组而不是单个实体上获取属性。我认为这与导航属性是否设置为标量有关,但切换它们并没有什么区别。
我确信我做错了什么,但我不知道是什么,我有点碰壁了。我已经从上到下阅读了文档,并尽我所能实现了这一点,但可能我有点困惑。
提前感谢您的帮助,如果我没有明确表示或提供足够的信息
我认为您的问题在于元数据
"name": "ProjectAuthor",
"entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "project_author_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
在导航属性Project->ProjectAuthor上,您告诉它它是一个标量,但它不在数据集中。。"项目作者":[{……….
我也遇到过这个问题。。99%的时间都是元数据问题,如果没有,那么就开始分割元数据,直到隔离错误。。尽管我确信这就是问题所在。。你需要一个hasMany和一个isScalar在反向导航上
相关文章:
- 函数未在Object.keys或Object.getOwnPropertyNames下列出,但可以调用
- delete在Object上效率低下,但在DOM Element's的数据属性,与null out相比
- 有没有一种方法可以列出Ember.Object的所有绑定
- 如何取消object.prototypes javascript的一个函数
- 为什么是文档.旧版应用程序中的DOM-object.properties为null
- 将*.js文件的内容放入Object中
- Object.prototype using 'this'
- 使用Object.create()的角度服务继承
- 如何使用object.assign()从其他对象引用基本对象属性
- 循环的数组推入在Object容器中具有不同的值
- reducers在redux中得到Function not Object,what'it’他错了
- JSON.stringify和Object.keys在同一个对象上产生不同的结果
- 在使用object.create创建的对象中使用super
- Join架构验证:Join.object定义数组中的有效键
- jquery打印[object XMLDocument]而不是文件内容
- ExtJS 4 Object.prototype fail
- JavaScript-从对象数组中输出随机OBJECT
- 为什么“{}+1”在Chrome和Firefox中排名第一,而字符串'[object object]1'
- 什么是“;原型;通过JavaScript中的Object Literal Notation创建的对象的链接
- TypeError:Object[Object Array]没有方法'getProperty'