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


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

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


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

示例1: function

'use strict';

import {Mongo} from 'meteor/mongo';

export const Parties = new Mongo.Collection<Party>('parties');

Parties.allow({
  insert: function(userId, party) {
    return true;
  },
  update: function(userId, party, fields, modifier) {
    return true;
  },
  remove: function(userId, party) {
    return true;
  }
});
开发者ID:Hongbo-Miao,项目名称:angular2-meteor-universal,代码行数:17,代码来源:parties.ts

示例2: insert

import { Mongo } from 'meteor/mongo';

export const Parties = new Mongo.Collection('parties');

Parties.allow({
  insert(userId, party) {
    return userId && party.owner === userId;
  },
  update(userId, party, fields, modifier) {
    return userId && party.owner === userId;
  },
  remove(userId, party) {
    return userId && party.owner === userId;
  }
});
开发者ID:AyushAnandChouksey,项目名称:meteor-angular-socially,代码行数:15,代码来源:collection.ts

示例3: function

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Projects } from '../collections/projects';
import { Email } from 'meteor/email';
import { MyFiles } from '../collections/my-files';
import { linkFilesModel } from './my-files';

export let Tasks = new Mongo.Collection<Task>('tasks');

Tasks.allow({
	insert: function(docId, doc: Task) {
		let access = false;
		let user = Meteor.user();
		let project = Projects.findOne({ _id: doc.project });
		project.users.forEach((up) => {
			if (up.userId === user._id) {
				access = true;
			}
		});
		return !!user && access;
	}
});

Meteor.methods({
	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);
开发者ID:djulls07,项目名称:projects-manager,代码行数:31,代码来源:tasks.ts

示例4: function

    _id: string;
    owner: string;
    userId: string;
    locked: boolean;
}

Posts = new Mongo.Collection<iPost>("posts");

Posts.allow({
    insert: function (userId: string, doc: iPost) {
        // the user must be logged in, and the document must be owned by the user
        return (userId && doc.owner === userId);
    },
    update: function (userId: string, doc: iPost, fields: string[], modifier: any) {
        // can only change your own documents
        return doc.owner === userId;
    },
    remove: function (userId: string, doc: iPost) {
        // can only remove your own documents
        return doc.owner === userId;
    },
    fetch: ['owner']
});

Posts.deny({
    update: function (userId: string, doc: iPost, fields: string[], modifier: any) {
        // can't change owners
        return doc.userId !== userId;
    },
    remove: function (userId: string, doc: iPost) {
        // can't remove locked documents
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:meteor-tests.ts

示例5: function

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';

export const MediaLibraries = new Mongo.Collection("mediaLibraries", { idGeneration: 'MONGO' });

MediaLibraries.allow({
    insert: function (userId, program) {
        return true;
    },
    update: function (userId, program) {
        return true;
    },
    remove: function (userId, program) {

        return true;
        //return userId && program.userId === userId;
    }
});
开发者ID:admirkb,项目名称:ads,代码行数:18,代码来源:medialibraries.ts

示例6: function

import {Mongo} from 'meteor/mongo';
import {ownsDocument} from '../../permissions'

export let BgmAudios = new Mongo.Collection('bgmAudios');

BgmAudios.allow({
  update: function(userId, post) { return ownsDocument(userId, post); },
  remove: function(userId, post) { return ownsDocument(userId, post); }
});
开发者ID:emastation,项目名称:webrpgtool_angular2,代码行数:9,代码来源:bgm_audios.ts

示例7: function

import {Mongo} from 'meteor/mongo';
import {ProjectModel} from '../models/projects.stream.model';
export let ProjectsStream = new Mongo.Collection<ProjectModel>('projectsstream');

ProjectsStream.allow({
  insert: function() {
    let user = Meteor.user();
    
    return !!user;
  },
  update: function() {
    let user = Meteor.user();
    
    return !!user;
  },
  remove: function() {
    let user = Meteor.user();
    
    return !!user;
  }
});
开发者ID:gab3alm,项目名称:lemonaidev3,代码行数:21,代码来源:projectsStream.ts

示例8: function

import {Mongo} from 'meteor/mongo';
import {Meteor} from 'meteor/meteor';
import {ConversationSubscriptionModel} from '../models/conv.subscriptions.model';
export const ConversationSubscriptions = new Mongo.Collection<ConversationSubscriptionModel>('convsubs');

ConversationSubscriptions.allow({
  insert: function() {
    let user = Meteor.user();
    
    return !!user;
  },
  update: function() {
    let user = Meteor.user();
    
    return !!user;
  },
  remove: function() {
    let user = Meteor.user();
    
    return !!user;
  }
});
开发者ID:gab3alm,项目名称:lemonaidev3,代码行数:22,代码来源:conversationSubscriptions.ts

示例9: function

import {Mongo} from 'meteor/mongo';
import {ownsDocument} from '../../permissions'

export let Background = new Mongo.Collection('backgrounds');

Background.allow({
  update: function(userId, post) { return ownsDocument(userId, post); },
  remove: function(userId, post) { return ownsDocument(userId, post); }
});
开发者ID:emastation,项目名称:webrpgtool_angular2,代码行数:9,代码来源:backgrounds.ts

示例10:

import { Mongo } from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';

export let Posts = new Mongo.Collection('posts');

Posts.allow({
  insert: () => {
    let user = Meteor.user();

    return !!user;
  },
  update: () => {
    let user = Meteor.user();

    return !!user;
  },
  remove: () => {
    let user = Meteor.user();

    return !!user;
  }
})
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:22,代码来源:posts.ts


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