Javascript 如何找到Orbit.js的链接关系
我似乎不知道如何让链接对象在Orbit.js中工作。我已经把源代码通读了几千遍(一点也不夸张:D),没有文档 我试过:Javascript 如何找到Orbit.js的链接关系,javascript,orbit.js,Javascript,Orbit.js,我似乎不知道如何让链接对象在Orbit.js中工作。我已经把源代码通读了几千遍(一点也不夸张:D),没有文档 我试过: memoryStore.findLinked("student", 1, "homeworks") 但这会返回错误: Uncaught Error: OC.LinkNotFoundException: student/1/homeworks 我的学生模式如下所示: PlanHW.models.schema.student = { attributes: { us
memoryStore.findLinked("student", 1, "homeworks")
但这会返回错误:
Uncaught Error: OC.LinkNotFoundException: student/1/homeworks
我的学生模式如下所示:
PlanHW.models.schema.student = {
attributes: {
username: {
type: 'string'
}
//...
},
links: {
homeworks: {
type: 'hasMany',
model: 'homework',
inverse: 'student'
}
}
};
PlanHW.models.schema.homework = {
attributes: {
title: {
type: 'string'
}
//...
},
links: {
student: {
type: 'hasOne',
model: 'student',
inverse: 'homeworks'
}
}
};
家庭作业模式如下所示:
PlanHW.models.schema.student = {
attributes: {
username: {
type: 'string'
}
//...
},
links: {
homeworks: {
type: 'hasMany',
model: 'homework',
inverse: 'student'
}
}
};
PlanHW.models.schema.homework = {
attributes: {
title: {
type: 'string'
}
//...
},
links: {
student: {
type: 'hasOne',
model: 'student',
inverse: 'homeworks'
}
}
};
我怎样才能查阅学生的家庭作业?在我看来,你想做的是
store.query(q => q.findRelatedRecords({type: 'student', id: student.id}, 'homeworks')
这会给你所有属于这个学生的作业