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


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

本文整理汇总了TypeScript中meteor/mongo.Mongo.Collection.attachSchema方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Mongo.Collection.attachSchema方法的具体用法?TypeScript Mongo.Collection.attachSchema怎么用?TypeScript Mongo.Collection.attachSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meteor/mongo.Mongo.Collection的用法示例。


在下文中一共展示了Mongo.Collection.attachSchema方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

  action.cardsEncoded = CardEncoder.encodeCards(action.cards);
  if (action.gameConfig) {
    action.gameConfig._deck_id = action.gameConfig.deck.id;
  } else {
  }
  return GamePlayActionCollection.insert(action);
}

if (Meteor.isServer) {
  Meteor.methods(
    {
      'fastcards.NewAction': function(action:GamePlayAction) {
        addAction(action, this.userId);
      },
      'fastcards.NewActions': function(actions:GamePlayAction[]) {
        let action:GamePlayAction = actions[0];
        let groupId = addAction(action, this.userId);
        for (let i=1; i<actions.length; i++) {
          action = actions[i];
          action.relatedActionId = groupId;
          addAction(action, this.userId);
        }
      }
    }
  );
}

GamePlayActionCollection.attachSchema(GamePlayActionSchema);


开发者ID:kokokenada,项目名称:for-real-cards,代码行数:28,代码来源:action.model.ts

示例2: Date

      if (this.isInsert) {
        return new Date();
      }
    },
    denyUpdate: true
  }
});

function unregisteredOrUser(userId, hand:Hand) {
  if (hand.userId) {
    return hand.userId === userId; // Only registered (logged in) creator may change
  }
  return true; // Wide open if user not registered    
}

HandCollection.allow({
  insert: function (userId, hand:Hand) {  
    return false; // Use a method
  },
  update: function (userId, hand:Hand) {
    return unregisteredOrUser(userId, hand);
  },
  remove: function (userId, hand:Hand) {
    return unregisteredOrUser(userId, hand);
  } 
});

HandCollection.attachSchema(HandSchema);
 

开发者ID:kokokenada,项目名称:for-real-cards,代码行数:28,代码来源:hand.model.ts

示例3: unregisteredOrCreator

        optional: true
    },
    password: {
      type: String,
      optional: true
    }
});

function unregisteredOrCreator(userId, game) {
  if (game.creatorId) {
    return game.creatorId === userId; // Only registered (logged in) creator may change
  }
  return true; // Wide open if, creator not registered    
}

GameCollection.allow({
  insert: function (userId, game) {
    return false; // Use method
  },
  update: function (userId, game) {
    return unregisteredOrCreator(userId, game);
  },
  remove: function (userId, game) {
    return unregisteredOrCreator(userId, game);
  } 
});

GameCollection.attachSchema(GamesSchema);
 

开发者ID:kokokenada,项目名称:for-real-cards,代码行数:28,代码来源:game.model.ts

示例4: getCreatedAtDate

import { MongoObservable } from "meteor-rxjs";
import { Mongo } from 'meteor/mongo';
import * as moment from "moment";

import { PlacesModel } from '../models/places.model';

let Places = new Mongo.Collection('places');

// fraction() {
//     return Fractions.findOne(this.fractionId);
// }

Places.helpers({
    getCreatedAtDate() {
        return moment(this.createdAt).format("DD.MM.YYYY HH:mm");
    }
});
Places.attachSchema(PlacesModel);
export const PlacesCollection = new MongoObservable.Collection(Places);
开发者ID:Nargott,项目名称:stalk.net,代码行数:19,代码来源:places.collection.ts

示例5: getCreatedAtDate

import { MongoObservable } from "meteor-rxjs";
import { Mongo } from 'meteor/mongo';
import * as moment from "moment";

import { FractionsModel } from '../models/fractions.model';

let Fractions = new Mongo.Collection('fractions');

Fractions.helpers({
    getCreatedAtDate() {
        return moment(this.createdAt).format("DD.MM.YYYY HH:mm");
    }
});
Fractions.attachSchema(FractionsModel);
export const FractionsCollection = new MongoObservable.Collection(Fractions);
开发者ID:Nargott,项目名称:stalk.net,代码行数:15,代码来源:fractions.collection.ts

示例6: getCreatedAtDate

import { MongoObservable } from "meteor-rxjs";
import { Mongo } from 'meteor/mongo';
import * as moment from "moment";

import { EventsModel } from '../models/events.model';

let Events = new Mongo.Collection('events');

Events.helpers({
    getCreatedAtDate() {
        return moment(this.createdAt).format("DD.MM.YYYY HH:mm");
    }
});
Events.attachSchema(EventsModel);
export const EventsCollection = new MongoObservable.Collection(Events);
开发者ID:Nargott,项目名称:stalk.net,代码行数:15,代码来源:events.collection.ts

示例7: getCreatedAtDate

import { MongoObservable } from "meteor-rxjs";
import { Mongo } from 'meteor/mongo';
import * as moment from "moment";
import {FractionsCollection} from "fractions.collection";

import { CharactersModel } from '../models/characters.model';

let Characters = new Mongo.Collection('characters');

// fraction() {
//     return Fractions.findOne(this.fractionId);
// }

Characters.helpers({
    // getFraction() {
    //     FractionsCollection.findOne({ _id: this.fractionId });
    // },
    getCreatedAtDate() {
        return moment(this.createdAt).format("DD.MM.YYYY HH:mm");
    }
});
Characters.attachSchema(CharactersModel);
export const CharactersCollection = new MongoObservable.Collection(Characters);
开发者ID:Nargott,项目名称:stalk.net,代码行数:23,代码来源:characters.collection.ts


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