本文整理匯總了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()
});
},