我正在寻找一个节点模块来进行mongo数据库迁移.到目前为止,我发现mongo-migrate,但不够强大.(总比没有好,但我需要更多,我习惯使用非常强大的Ruby迁移!)
几个星期前我找到了另一个,功能强大,但没有处理mongoDb,只有MySQL,PostGre等等.
你知道一个可以帮助我的模块或东西吗?我的意思是,我不是第一个想要处理数据库迁移的人,你如何管理?我的项目很大,我需要控制.
这是我到目前为止所做的一个例子:
*0010-init_category_table.js*
var mongodb = require('mongodb');
exports.up = function(db, next){
var documentName = 'category';
var collection = mongodb.Collection(db, documentName);
var index;
var indexOptions;
/**
* Create indexes.
*/
index = { "code": 1 };
indexOptions = { unique: true };
collection.ensureIndex( index, {unique: true, w: 1}, function(error, data){
console.log(error ? error : documentName + ': [ensureIndex] ' + JSON.stringify(index) + JSON.stringify(indexOptions));
});
index = { "name": 1 };
indexOptions = { unique: true };
collection.ensureIndex( …Run Code Online (Sandbox Code Playgroud)