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