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


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

本文整理汇总了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;
});
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:meteor-tests.ts

示例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);
  }
});

开发者ID:emastation,项目名称:webrpgtool_angular2,代码行数:17,代码来源:codes.ts

示例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 }
})
开发者ID:nebiljabari,项目名称:RESTberry_Pi,代码行数:12,代码来源:quotes.ts

示例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);
  }
});
开发者ID:emastation,项目名称:webrpgtool_angular2,代码行数:16,代码来源:maps.ts


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