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