更新时间:2023-02-12 08:33:28
使用 mongo-counter包,可以使用方法incrementCounter(name)
创建一个增量器.该实现基于创建一个自动递增序列字段无需访问流星集合即可直接访问数据库.
Using the mongo-counter package, is posible to create an incrementer with the method incrementCounter(name)
. The implementation is based on Create an Auto-Incrementing Sequence Field accessing directly the database without going through a Meteor Collection.
Meteor.methods({
'addRecord':function(doc) {
doc.id = incrementCounter('docId');
MyCollection.insert(doc);
return doc.id;
}
});
更新
Atmosphere上有新的mongo计数器包,可能比我最初的建议要好.
There are new mongo counter packages on Atmosphere, probably better than my initial recommendation.