Reputation: 729
So, i'm creating collection as suggested in angular2-meteor boilerplate:
export const BookCollection = new MongoObservable.Collection<Book>('books');
So, if i write something like this:
BookColletion.insert(..., callback_f);
I'm getting an error, that second parameter does not exists. So, how i supposed to get last inserted document's id?
Upvotes: 2
Views: 509
Reputation: 1573
You can get the inserted id like this:
var insertedId = BookColletion.collection.insert();
as mentioned here
Upvotes: 2
Reputation: 21384
I'm not sure what MongoObservable
is, nor what that <Book>
syntax means, but I suspect that what you want is something like this:
export const BookCollection = new Mongo.Collection('books');
BookCollection.find().observe({
added(document) {
// document is the newly added document
}
});
Upvotes: 2