获取MongoDb中Collection的最后一个id值, 自增. MongoDb本身自带的_id用的是uuid, 运算成本太高了, 非常不实用, 所以用这个替代.
var mg = require('mglastone')
mg.MGConfig('mongodb://localhost:1700/MGLastOne')
mg.MGLastOneAsync('aaa')
.then(function(m) {
console.log(m)
})
.catch(function(error) {
console.log(error)
})
- MGConfig -- 配置mongodb服务
- MGLastOne -- 递增获取ID值
- MGLastOneAsync -- 递增获取ID值, promise模式
- MGSetValue -- 手动设置ID值, 用在批量配置id值之后
- MGSetValueAsync -- 手动设置ID值, promise模式
npm install mglastone