Meteor-Community-Packages / meteor-simple-schema

Meteor integration package for simpl-schema
https://github.com/Meteor-Community-Packages/meteor-simple-schema
MIT License
920 stars 162 forks source link

Bulk insert #697

Closed haojia321 closed 7 years ago

haojia321 commented 7 years ago

Will simple schema still work if I use bulk insert? https://docs.mongodb.com/manual/reference/method/Bulk.insert/#Bulk.insert

We need to write below code to achieve Mongodb's bulk insert var bulk = UserNotifications.rawCollection().initializeUnorderedBulkOp(); ... bulk.execute();

aldeed commented 7 years ago

No, you'll need to validate all docs before inserting

haojia321 commented 7 years ago

Hi @aldeed, Yes, thats what we are doing now. We use check(obj, collection.simpleschema()); to check if obj is valid.

So if I have autoValue been set in simpleschema, do you know if their is a way I can programmatically generate the autoValue before use check()?