當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Mongo.Collection.find方法代碼示例

本文整理匯總了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 })
    ];
});
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:meteor-tests.ts

示例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})
   ];
 });
開發者ID:kokokenada,項目名稱:for-real-cards,代碼行數:9,代碼來源:avatar.model.ts

示例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
				}
			}
		});
	},
開發者ID:djulls07,項目名稱:projects-manager,代碼行數:35,代碼來源:tasks.ts

示例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;
}
開發者ID:djulls07,項目名稱:projects-manager,代碼行數:33,代碼來源:my-files.ts

示例5: function

 Meteor.publish('tasks.public', function() {
   return Tasks.find({
     $or: [
       { private: { $ne: true } },
       { owner: this.userId }
     ]
   });
 });
開發者ID:RichardHwang886,項目名稱:todo4,代碼行數:8,代碼來源:tasks.ts

示例6:

 Meteor.startup(function () {
     if (Rooms.find().count() === 0) {
         Rooms.insert({ name: "Initial room" });
     }
 });
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:5,代碼來源:meteor-tests.ts


注:本文中的meteor/mongo.Mongo.Collection.find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。