Skip to content

Instantly share code, notes, and snippets.

@alyssaq
Created August 30, 2014 06:05
Show Gist options
  • Save alyssaq/4f0287cb1ec4c1a17daf to your computer and use it in GitHub Desktop.
Save alyssaq/4f0287cb1ec4c1a17daf to your computer and use it in GitHub Desktop.
Clear all and batch create documents with Mongoose
var plans = [ { plan: 1,
users: 3,
amount: 18,
name: 'Micro',
billingPeriod: 'Month' },
{ plan: 2,
users: 8,
amount: 40,
name: 'Mini',
billingPeriod: 'Month' },
{ plan: 3,
users: 21,
amount: 84,
name: 'Medium',
billingPeriod: 'Month' },
{ plan: 4,
users: 55,
amount: 165,
name: 'Monster',
billingPeriod: 'Month'},
{ plan: 5,
users: 3,
amount: 180,
name: 'Micro',
billingPeriod: 'Year' },
{ plan: 6,
users: 8,
amount: 400,
name: 'Mini',
billingPeriod: 'Year' },
{ plan: 7,
users: 21,
amount: 840,
name: 'Medium',
billingPeriod: 'Year' },
{ plan: 8,
users: 55,
amount: 1650,
name: 'Monster',
billingPeriod: 'Year'} ];
planModel.find({}).remove(function (err, data) {
if (!err) {
console.log('good', data);
PaymentPlanModel.create(plans);
} else {
console.error(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment