本文整理汇总了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;
}
});
示例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;
}
});
示例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);
示例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
示例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;
}
});
示例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); }
});
示例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;
}
});
示例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;
}
});
示例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); }
});
示例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;
}
})