我有三个模型:> mocha lib/test/
Redis IO Works as expected
Can GET/SET
1) Should be able to SET {Key, Value} Pair
2) Should be able to GET Value from Key
Can DEL
3) Should be able to DEL Key from Redis DB
0 passing (13ms)
3 failing
1) Redis IO Works as expected Can GET/SET Should be able to SET {Key, Value} Pair:
AssertionError: expected 1 to equal 0
+ expected - actual
-1
+0
at Context.<anonymous> (lib/test/redis_test.js:11:38)
2) Redis IO Works as expected Can GET/SET Should be able to GET Value from Key:
AssertionError: expected [ '', 1 ] to equal 'value'
at Context.<anonymous> (lib/test/redis_test.js:15:40)
3) Redis IO Works as expected Can DEL Should be able to DEL Key from Redis DB:
AssertionError: expected 1 to equal 0
+ expected - actual
-1
+0
at Context.<anonymous> (lib/test/redis_test.js:24:21)
,User
和Group
。用户通过会员资格拥有多个群组。我有一个表单来邀请新用户并一次将它们分配给零个或多个组。
我希望发送给Membership
服务器的JSON看起来像
POST /users
我尝试将{
data: {
type: 'user',
id: null,
attributes: { name: 'Sam Sample' }
},
relationships: {
memberships: {
data: [
{
type: 'membership',
id: null,
relationships: {
group: {
data: {
type: 'group',
id: 12345
}
}
}
},
{
type: 'membership',
id: null,
relationships: {
group: {
data: {
type: 'group',
id: 67890
}
}
}
}
]
}
}
}
添加到相关的序列化程序中:
serialize: true
这让我得到了我想要的JSON的一些,但不是全部。具体来说,我得到了// serializer:user
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
attrs: {
memberships: { serialize: true }
}
})
// serializer:membership
import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
attrs: {
group: { serialize: true }
}
})
个对象,但没有得到membership
个对象
group