本文整理汇总了TypeScript中meteor/check.Match.Where方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Match.Where方法的具体用法?TypeScript Match.Where怎么用?TypeScript Match.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meteor/check.Match
的用法示例。
在下文中一共展示了Match.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
hCurObserver: Meteor.LiveQueryHandle,
hAutoNotify?: Tracker.Computation) {
check(hAutoNotify, Match.Optional(Tracker.Computation));
check(hCurObserver, Match.Where(function(observer) {
return !!observer.stop;
}));
this._hAutoNotify = hAutoNotify;
this._hCurObserver = hCurObserver;
}
示例2: initMethods
import { Meteor } from 'meteor/meteor';
import { Chats, Messages } from "../collections/whatsapp-collections";
import { check, Match } from "meteor/check";
import { Profile } from "api/models/whatsapp-models";
const nonEmptyString = Match.Where((str) => {
check(str, String);
return str.length > 0;
});
export function initMethods() {
Meteor.methods({
addChat(receiverId: string): void {
if (!this.userId) throw new Meteor.Error('unauthorized',
'User must be logged-in to create a new chat');
check(receiverId, nonEmptyString);
if (receiverId == this.userId) throw new Meteor.Error('illegal-receiver',
'Receiver must be different than the current logged in user');
const chatExists = !!Chats.collection.find({
memberIds: {$all: [this.userId, receiverId]}
}).count();
if (chatExists) throw new Meteor.Error('chat-exists',
'Chat already exists');
const chat = {
memberIds: [this.userId, receiverId]
};
示例3: check
import {Mongo} from 'meteor/mongo';
import { Meteor } from 'meteor/meteor';
import {check} from 'meteor/check';
import { Match } from 'meteor/check'
export const Parties = new Mongo.Collection('parties');
Meteor.methods({
'addItem'(_data) {
const NonEmptyString = Match.Where(function (x) {
check(x, String);
return x.length > 0;
});
check(_data.title, NonEmptyString);
check(_data.message, NonEmptyString);
Parties.insert({
title: _data.title,
message: _data.message,
created_date: new Date()
});
}
})
if (Meteor.isServer) {
Meteor.publish('parties', function () {
return Parties.find();
});