Closed mjyc closed 7 years ago
The _id of documents in the after.insert hooks are no longer strings, but objects.
_id
after.insert
For example, using the following code
Collection.after.insert( function(userId, obj) { console.log(obj._id); } )
We get the following outputs:
I20161214-00:51:38.409(-8)? local addition of { result: I20161214-00:51:38.409(-8)? { ok: 1, I20161214-00:51:38.410(-8)? n: 1, I20161214-00:51:38.411(-8)? opTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1481705498 } }, I20161214-00:51:38.411(-8)? ops: I20161214-00:51:38.411(-8)? [ { name: 'Room 123', I20161214-00:51:38.411(-8)? phone: '', I20161214-00:51:38.411(-8)? floorId: 'savidev/1', I20161214-00:51:38.412(-8)? pose: [Object], I20161214-00:51:38.412(-8)? goalarea: '', I20161214-00:51:38.412(-8)? doorOpensOut: false, I20161214-00:51:38.412(-8)? hidden: false, I20161214-00:51:38.412(-8)? _id: 'RmkvkGRjZ8DoLMqPy' } ], I20161214-00:51:38.412(-8)? insertedCount: 1, I20161214-00:51:38.412(-8)? insertedIds: [ 'RmkvkGRjZ8DoLMqPy' ] }
However, we expect obj._id to be the _id of the inserted document ("RmkvkGRjZ8DoLMqPy" in the above).
obj._id
Tested in Meteor 1.4.2.3.
Could you show me your package versions?
It was matb33:collection-hooks@0.8.1
matb33:collection-hooks@0.8.1
Have you tried updating?. This bug was solved afaik
Updated to 0.8.4 and I did not have the above problem anymore. Thank you.
:)
The
_id
of documents in theafter.insert
hooks are no longer strings, but objects.For example, using the following code
We get the following outputs:
However, we expect
obj._id
to be the_id
of the inserted document ("RmkvkGRjZ8DoLMqPy" in the above).Tested in Meteor 1.4.2.3.