【发布时间】:2013-05-25 03:51:28
【问题描述】:
获取诸如 ['hello', 'there'] 之类的数组并将其存储在具有诸如
之类的架构的 Mongoose 文档中tags: { type: Array }
使用诸如:
Something.create({ tags: ['hello', 'there']}, cb);
然后使用 ShouldJS 检查文档是否与我提供的数组匹配,我希望这样:
doc.tags.should.eql(['hello', 'there']);
但事实并非如此。如果我 console.log 文档标签,我会得到:
[hello, there]
请注意引号已消失。 doc.tags 确实是一个数组(我可以检查 instanceof 数组),我也可以将 shouldjs 与
一起使用doc.tags.should.have.keys('hello');
doc.tags.should.have.keys('there');
有人知道为什么我的数组不再匹配了吗?
【问题讨论】:
-
愚蠢的问题,可能是一种类型,但是当您输出时,您会得到 [hello, there] 或 ['hello', 'there'] 因为它们不相等
-
你有没有得到这个问题的答案?我也有同样的问题
-
@dworrad - 不,从来没想过。
标签: javascript node.js mongoose should.js