本文整理汇总了TypeScript中meteor/mongo.Mongo.Collection.find方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Mongo.Collection.find方法的具体用法?TypeScript Mongo.Collection.find怎么用?TypeScript Mongo.Collection.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meteor/mongo.Mongo.Collection
的用法示例。
在下文中一共展示了Mongo.Collection.find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
Meteor.publish("roomAndMessages", function (roomId: string) {
check(roomId, String);
return [
Rooms.find({ _id: roomId }, { fields: { secretInfo: 0 } }),
Messages.find({ roomId: roomId })
];
});
示例2: 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})
];
});
示例3: function
addMessageTask: function (taskId: string, message: string) {
check(taskId, String);
check(message, String);
if (!message.length || message.length < 3) {
throw new Meteor.Error('400', 'message-to-short');
}
if (message.length > 1024) {
throw new Meteor.Error('400', 'message-to-long');
}
// verif user & task
let user = Meteor.user();
if (!user) {
throw new Meteor.Error('403', 'not-authorized');
}
let task = Tasks.find({
_id: taskId,
$or: [
{ owner: this.userId },
{ 'targets.userId': this.userId }
]
});
if (!task) {
throw new Meteor.Error('403', 'not-authorized');
}
Tasks.update(taskId, {
$push: {
conversation: {
message: message,
createdAt: new Date(),
owner: user._id,
ownerEmail: user.emails[0].address
}
}
});
},
示例4: linkFilesModel
export function linkFilesModel(projectId: string, modelName: string, modelId: string, filesIds: Array<string>) {
let ret = true;
// check if has right to upload more files for the projectId
let files = MyFiles.find({ $or: [{ projectId: projectId }, { _id: { $in: filesIds } }] });
let size = 0;
files.forEach((file) => {
size += file.size;
});
if (size > process.env.FILES_SIZE_PROJECT) {
console.log('No space anymore', size + ' > ' + process.env.FILES_SIZE_PROJECT);
ret = false; // not linking files will result in their removing
}
if (ret) {
console.log('files ids', filesIds);
MyFiles.update(
{
_id: { $in: filesIds }
},
{
$set: {
modelName: modelName,
modelId: modelId,
projectId: projectId
}
},
{
multi: true
}
);
}
return ret;
}
示例5: function
Meteor.publish('tasks.public', function() {
return Tasks.find({
$or: [
{ private: { $ne: true } },
{ owner: this.userId }
]
});
});
示例6:
Meteor.startup(function () {
if (Rooms.find().count() === 0) {
Rooms.insert({ name: "Initial room" });
}
});