Open rootedsoftware opened 9 years ago
This package supports whatever Meteor's mongo package supports. I don't think it supports bulk insert.
It does support bulk inserts. If I remove the schema for this collection Meteor inserts the documents from the array without an issue.
OK, then we should probably support them, too. It doesn't seem to be a documented feature, though.
@c316 see https://github.com/meteor/meteor/issues/1255#issuecomment-97276160
I will wait until Meteor officially supports this, but we can keep this issue open to track.
Any updates on this, I'm getting the error "Error: 0 is not allowed by the schema " when trying to do a bulk insert, and it appears Meteor now fully supports Bulk inserts.
Agreed. Running into the same issue.
+1 on this one :)
Hi @aldeed is there an interim way for us to use bulk inserts? Need this.
Thanks for your help.
@myyellowshoe @nicooprat @SharadKumar
Way back in February I used the mikowals:batch-insert package to do batch insert. It worked (at least back then when I was using -v < 1.3), but I've since modified my database schema in favor of a more efficient structure that did not require batch inserting. It just wasn't performant, especially with Meteor. Just my own experience though.
Also ran into a huge bottleneck with doing schema validation on large database operations, which makes sense. I had to selectively skip validation for a few operations which obviously is not ideal. So it's important to recognize the advantages and disadvantages of no-sql when doing this sort of stuff.
It's only in the NodeJS driver: https://mongodb.github.io/node-mongodb-native/api-generated/collection.html#insert
But not supported by Collection / Collection2: https://docs.meteor.com/api/collections.html#Mongo-Collection-insert
export const Tags: any = new Mongo.Collection('tags');
export const TagsSchema = new SimpleSchema({
name: {
type: String,
min: 3,
max: 30
}
},
{
clean: {
filter: true,
autoConvert: true,
removeEmptyStrings: true,
trimStrings: true,
getAutoValues: true,
removeNullsFromArrays: true,
}
}
);
Tags.attachSchema(TagsSchema);
Tags.insert([ { name: 'yxc' }, { name: 'cvb' } ], {bypassCollection2: true});
It always puts them into one document:
{ "_id" : "tT9KxRZa2zvQEsp6u", "0" : { "name" : "yxc" }, "1" : { "name" : "cvb" } }
Alternatives here: https://docs.meteor.com/api/collections.html#Mongo-Collection-insert
Does this package support bulk insert operations? I have an array of documents (with _id's) and I want to insert them with a single command, but it appears that this isn't supported.