本文整理汇总了TypeScript中meteor/mongo.Mongo.Collection.deny方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Mongo.Collection.deny方法的具体用法?TypeScript Mongo.Collection.deny怎么用?TypeScript Mongo.Collection.deny使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meteor/mongo.Mongo.Collection
的用法示例。
在下文中一共展示了Mongo.Collection.deny方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
// 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
return doc.locked;
},
fetch: ['locked'] // no need to fetch 'owner'
});
/**
* From Collections, cursor.forEach section
*/
var topPosts = Posts.find({}, { sort: { score: -1 }, limit: 5 });
var count = 0;
topPosts.forEach(function (post: { title: string }) {
console.log("Title of post " + count + ": " + post.title);
count += 1;
});
示例2: function
import {Mongo} from 'meteor/mongo';
import {ownsDocument} from '../../permissions'
import * as _ from 'lodash';
export let Codes = new Mongo.Collection('codes');
Codes.allow({
update: function(userId, post) { return ownsDocument(userId, post); },
remove: function(userId, post) { return ownsDocument(userId, post); }
});
Codes.deny({
update: function(userId, post, fieldNames) {
// may only edit the following two fields:
return (_.without(fieldNames, 'title', 'javascript').length > 0);
}
});
示例3: insert
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
// Declare the Mongo.Collection
export const Quotes = new Mongo.Collection('quotes');
// Deny the client direct access to the Collection
Quotes.deny({
insert() { return true },
update() { return true },
remove() { return true }
})
示例4: function
import {Mongo} from 'meteor/mongo';
import {ownsDocument} from '../../permissions'
export let Maps = new Mongo.Collection('maps');
import * as _ from 'lodash';
Maps.allow({
update: function(userId, post) { return ownsDocument(userId, post); },
remove: function(userId, post) { return ownsDocument(userId, post); }
});
Maps.deny({
update: function(userId, post, fieldNames) {
// may only edit the following two fields:
return (_.without(fieldNames, 'title', 'width', 'height', 'type_array', 'height_array', 'script_array', 'game_id').length > 0);
}
});