本文整理汇总了TypeScript中meteor/mongo.Mongo.Collection类的典型用法代码示例。如果您正苦于以下问题:TypeScript Mongo.Collection类的具体用法?TypeScript Mongo.Collection怎么用?TypeScript Mongo.Collection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mongo.Collection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
Meteor.publish('common-app.avatar-images', function (_id, counter) {
if (!_.isArray(_id))
_id = [_id];
return [
AvatarOriginalCollection.find({_id: {$in: _id}, userId: this.userId}),
AvatarMediumCollection.find({_id: {$in: _id}, userId: this.userId}),
AvatarThumbCollection.find({_id: {$in: _id}, userId: this.userId})
];
});
示例2: addAction
function addAction(action:GamePlayAction, userId:string):string {
if (action.creatorId !== userId)
throw new Meteor.Error('invalid-user', 'current userId does not match user ID of passed object');
checkUser(action.gameId, action.creatorId);
action.cardsEncoded = CardEncoder.encodeCards(action.cards);
if (action.gameConfig) {
action.gameConfig._deck_id = action.gameConfig.deck.id;
} else {
}
return GamePlayActionCollection.insert(action);
}
示例3: function
archiveTask: function (taskId: string, compt?: number) {
check(taskId, String);
let c = compt || 0;
let user = Meteor.user();
let task = Tasks.findOne(taskId);
let auth = false;
if (!user || !task) {
throw new Meteor.Error('not-authorized');
}
let project = Projects.findOne(task.project);
if (!project) {
throw new Meteor.Error('404', 'project-not-found');
}
if (task.owner === user._id) {
auth = true;
}
if (user._id === project.owner) {
auth = true;
}
if (!auth) {
throw new Meteor.Error('not-authorized');
}
Tasks.update(taskId, {
$set: {
archived: true,
archivor: user._id
}
});
if (task.hasSubTasks) {
// on update et complete les sub tasks (qui ne le sont pas uniquement).
Tasks.update(
{
parentTask: task._id,
archived: false,
},
{
$set: {
archivor: user._id,
archived: true
}
},
{
multi: true
}
);
if (c >= 100) {
throw new Meteor.Error('500', 'too-many-rec');
}
task.subTasks.forEach((subTaskId) => {
Meteor.call('archiveTask', subTaskId, c+1);
});
}
},
示例4: function
'tasks.addTask': function(text) {
Tasks.insert({
text: text,
checked: false,
private: false
});
},
示例5: function
Meteor.publish("counts-by-room", function (roomId: string) {
var self = this;
check(roomId, String);
var count = 0;
var initializing = true;
var handle = Messages.find({ roomId: roomId }).observeChanges({
added: function (id: any) {
count++;
// if (!initializing)
// this.changed("counts", roomId, {count: count});
},
removed: function (id: any) {
count--;
// Todo: Not sure how to define in typescript
// self.changed("counts", roomId, {count: count});
}
});
initializing = false;
// Todo: Not sure how to define in typescript
// self.added("counts", roomId, {count: count});
self.ready();
self.onStop(function () {
handle.stop();
});
});
示例6: function
destroyComponentUpload: function() {
// On retire tous les fichiers non link a au moins 1 projet et appartenant au user co.
// finalement on ne regarde meme pas filesIds
/*let f = MyFiles.find({ userId: Meteor.userId(), projectId: { $exists: false } });
console.log('Files will be removed (destroyed component):', f.count());*/
MyFiles.remove({ userId: Meteor.userId(), projectId: {$exists: false} });
},
示例7: recordEvent
export function recordEvent(charId: number, text: string) {
EventLog.insert({
text: text,
time: new Date(),
charid: charId,
});
}
示例8: function
'tasks.addTask': function(text: string) {
Tasks.insert({
text: text,
checked: false,
private: false,
createdAt: new Date()
});
},