當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。