我有MongoCollection
一个aldeed:simple-schema
附件,其中content
属性的类型为Object
:
以下代码将文档写入控制台,然后将其插入,然后获取具有正确 id 的文档并将其写入控制台:
console.log(doc);
const id = notes.collection.insert(doc);
let newdoc = notes.collection.findOne({_id: id});
console.log(newdoc);
在循环操作期间,内容属性的对象内的值会丢失。
插入前:
I20160304-16:52:24.722(-5)? { doctorId: 'xD7FiSfYdqwk94gQ6',
I20160304-16:52:24.723(-5)? patientId: '4wG3nnkzrfH4W2hsG',
I20160304-16:52:24.723(-5)? created: 1457128344,
I20160304-16:52:24.723(-5)? type: 'note',
I20160304-16:52:24.727(-5)? content: { noteText: 'Test' } }
从数据库中检索时:
I20160304-16:52:24.734(-5)? { _id: 'w6rRoMqtJc5EKFKFs',
I20160304-16:52:24.735(-5)? doctorId: 'xD7FiSfYdqwk94gQ6',
I20160304-16:52:24.735(-5)? patientId: '4wG3nnkzrfH4W2hsG',
I20160304-16:52:24.735(-5)? created: 1457128344,
I20160304-16:52:24.736(-5)? type: 'note',
I20160304-16:52:24.736(-5)? content: {} }
我不明白为什么会这样。这是简单模式中内容属性的规范:
Carin.subschemas.object = {
type: Object,
optional: false
};