-
-
Save stevepm/da79a328b972e0484dac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.env.IS_MIRROR) { | |
Meteor.methods({ | |
'loadFixtures': function(){ | |
console.log('Loading default fixtures'); | |
// TODO: add your fixtures here | |
// Example below: | |
//*****EXAMPLE******** | |
//Accounts.createUser({ | |
// email: 'email@example.com', | |
// password: '123456' | |
//}); | |
//*****EXAMPLE******** | |
console.log('Finished loading default fixtures'); | |
}, | |
'clearDB': function(){ | |
console.log('Clear DB'); | |
var collectionsRemoved = 0; | |
var db = Meteor.users.find()._mongo.db; | |
db.collections(function (err, collections) { | |
var appCollections = _.reject(collections, function (col) { | |
return col.collectionName.indexOf('velocity') === 0 || | |
col.collectionName === 'system.indexes'; | |
}); | |
_.each(appCollections, function (appCollection) { | |
appCollection.remove(function (e) { | |
if (e) { | |
console.error('Failed removing collection', e); | |
fut.return('fail: ' + e); | |
} | |
collectionsRemoved++; | |
console.log('Removed collection'); | |
if (appCollections.length === collectionsRemoved) { | |
console.log('Finished resetting database'); | |
} | |
}); | |
}); | |
}); | |
console.log('Finished clearing'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment