当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Mongo.Collection.insert方法代码示例

本文整理汇总了TypeScript中meteor/mongo.Mongo.Collection.insert方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Mongo.Collection.insert方法的具体用法?TypeScript Mongo.Collection.insert怎么用?TypeScript Mongo.Collection.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meteor/mongo.Mongo.Collection的用法示例。


在下文中一共展示了Mongo.Collection.insert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: recordEvent

export function recordEvent(charId: number, text: string) {
  EventLog.insert({
    text: text,
    time: new Date(),
    charid: charId,
  });
}
开发者ID:paralin,项目名称:evewaitlist,代码行数:7,代码来源:events.ts

示例2: function

 'tasks.addTask': function(text) {
   Tasks.insert({
     text: text,
     checked: false,
     private: false
   });
 },
开发者ID:RichardHwang886,项目名称:todo4,代码行数:7,代码来源:tasks.ts

示例3: function

 'tasks.addTask': function(text: string) {
   Tasks.insert({
     text: text,
     checked: false,
     private: false,
     createdAt: new Date()
   });
 },
开发者ID:DAB0mB,项目名称:angular2-meteor,代码行数:8,代码来源:tasks.ts

示例4: 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);
}
开发者ID:kokokenada,项目名称:for-real-cards,代码行数:11,代码来源:action.model.ts

示例5: function

	addProject: function (name: string) {
		check(name, String);

		let user = Meteor.user();
		if (!user || user.emails[0].address !== 'djulls07@gmail.com') {
			throw new Meteor.Error('not-authorized');
		}

		let project = {
			name: name,
			owner: user._id,
			ownerEmail: user.emails[0].address,
			createdAt: new Date(),
			users: [{ userId: user._id, email: user.emails[0].address }],
			groups: []
		}
		
		let id = Projects.insert(project);
		console.log('project saved: ', id);
	},
开发者ID:djulls07,项目名称:projects-manager,代码行数:20,代码来源:projects.ts

示例6:

 Meteor.startup(function () {
     if (Rooms.find().count() === 0) {
         Rooms.insert({ name: "Initial room" });
     }
 });
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:5,代码来源:meteor-tests.ts

示例7: function

	addTask: function(task: Task, notifyTargets: boolean, parentTaskId?: string) {
		check(task.project, String);
		check(task.name, String);
		check(task.priority, String);
		check(task.dueDate, Date);
		check(task.description, String);
		check(notifyTargets, Boolean);

		let parentTask = null;
		let project = Projects.findOne(task.project);
		let isSubTask = false;
		if (!project) {
			throw new Meteor.Error('404', 'project-not-found');
		}

		if (parentTaskId) {
			parentTask = Tasks.findOne(parentTaskId);
			if (!parentTask) {
				throw new Meteor.Error('404', 'parent-task-not-found');
			}
			isSubTask = true;
		}
		if (!task.targets || task.targets.length === 0) {
			throw new Meteor.Error('400', 'Please select at least one target');
		}
		// verif et retrait des doublons targets
		let targets = [];
		let ids = {};
		task.targets.forEach((target) => {
			if (ids[target.userId] === true) return;
			targets.push(target);
			ids[target.userId] = true;
		});
		task.targets = targets;

		let user = Meteor.user();
		task.owner = user._id;
		task.ownerEmail = user.emails[0].address;
		task.createdAt = new Date();
		task.validated = false;
		task.archived = false;
		task.completed = false;
		task.conversation = [];
		task.isSubTask = isSubTask;
		task.hasSubTasks = false;
		task.subTasks = [];
		task.parentTask = parentTaskId || null;

		let taskId = Tasks.insert(task);
		
		let linking = linkFilesModel(project._id, 'task', taskId, task.files);
		if (!linking) {
			Tasks.remove(taskId);
			throw new Meteor.Error('403', 'No more space for files');
		}		
		// update parent task if needed
		if (parentTaskId) {
			Tasks.update(parentTaskId, {
				$push: {
					subTasks: taskId
				},
				$set: {
					hasSubTasks: true
				}
			});
		}
		// si server et param notify == true:
		this.unblock();
		if (Meteor.isServer && notifyTargets) {
			
			// send email to targets
			task.targets.forEach((target) => {
				let to = target.email;
				Email.send({
					to: to,
					from: process.env.MAIL_FROM,
					subject: 'You have a new task',
					text: 'New task ['+task.name+'] on project: '+project.name+', added by ' + task.ownerEmail
				});
			});
		}
		console.log('Task saved: ', taskId);
		return taskId;
	},
开发者ID:djulls07,项目名称:projects-manager,代码行数:84,代码来源:tasks.ts

示例8: check

    return !!user;
  }
});

Meteor.methods({
  // Insert Task
  'tasks.insert' (task) {
    check(task.name, String);
    check(task.status,String);
    // Make sure the user is logged in before inserting a task
    if (!Meteor.userId()) {
      throw new Meteor.Error('not-authorized');
    }
    Tasks.insert({
      name:task.name,
      status:task.status,
      owner: Meteor.userId(),
      created:new Date()
    });
  },
  'tasks.remove' (taskId) {
    console.log('removing tasks from collection');
    check(taskId, String);
	const task = Tasks.findOne(taskId);
    //if (task.private && task.owner !== Meteor.userId()) {
		//changed when got error in test...
	if (task.owner !== Meteor.userId()) {
      // If the task is private, make sure only the owner can delete it
      throw new Meteor.Error('not-authorized');
    }
    Tasks.remove(taskId);
  },
开发者ID:LIOSK-ORG,项目名称:todo-app,代码行数:32,代码来源:tasks.ts

示例9: tasksPublication

import {Mongo} from 'meteor/mongo';

export let Test = new Mongo.Collection('test');

if (Meteor.isServer) {
  // This code only runs on the server
  Meteor.publish('test', function tasksPublication() {
    return Test.find();
  });
}

Meteor.methods({

    'test.get' ()  {

        return Test.find().fetch();
    },
    
    'test.insert' ()  {
       return Test.insert({title: "buhu", body: "this is the body"});
    },

});
开发者ID:ionutleustean,项目名称:irian-meteor-app,代码行数:23,代码来源:test.ts


注:本文中的meteor/mongo.Mongo.Collection.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。