I have a MongoCollection
with a aldeed:simple-schema
attached, where the content
property has the type Object
:
The following code writes the document to console, then inserts it, then fetches the document with the correct id and writes this to console:
console.log(doc);
const id = notes.collection.insert(doc);
let newdoc = notes.collection.findOne({_id: id});
console.log(newdoc);
During the round-robin operation the value inside the object of the content property is lost.
Before the insert:
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' } }
When retrieved from the database:
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: {} }
I don't understand why this happens. This is the specification of the content attribute in the simple-schema:
Carin.subschemas.object = {
type: Object,
optional: false
};