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


TypeScript Meteor.publish方法代码示例

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


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

示例1: initPublications

export function initPublications() {
  Meteor.publish('users', function(): Mongo.Cursor<User> {
    if (!this.userId) return;

    return Users.collection.find({}, {
      fields: {
        profile: 1
      }
    });
  });

  Meteor.publish('messages', function(chatId: string): Mongo.Cursor<Message> {
    if (!this.userId) return;
    if (!chatId) return;

    return Messages.collection.find({chatId});
  });

  Meteor.publishComposite('chats', function() {
    if (!this.userId) return;

    return {
      find: () => {
        return Chats.collection.find({memberIds: this.userId});
      },

      children: [
        {
          find: (chat) => {
            return Messages.collection.find({chatId: chat._id}, {
              sort: {createdAt: -1},
              limit: 1
            });
          }
        },
        {
          find: (chat) => {
            return Users.collection.find({
              _id: {$in: chat.memberIds}
            }, {
              fields: {profile: 1}
            });
          }
        }
      ]
    };
  });
}
开发者ID:pro-to-tip,项目名称:pro-to-tip.github.io,代码行数:48,代码来源:publications.ts

示例2: function

export default function () {
  Meteor.publish('posts.list', function () {
    const selector = {};
    const options = {
      fields: {_id: 1, title: 1},
      sort: {createdAt: -1},
      limit: 10
    };

    return Posts.find(selector, options);
  });

  Meteor.publish('posts.single', function (postId: string) {
    check(postId, String);
    const selector = {_id: postId};
    return Posts.find(selector);
  });

  Meteor.publish('posts.comments', function (postId: string) {
    check(postId, String);
    const selector = {postId};
    return Comments.find(selector);
  });
}
开发者ID:TribeMedia,项目名称:meteor-mantra-redux-graphql,代码行数:24,代码来源:posts.ts

示例3: function

import {Orders} from '../collections/orders';
import {Meteor} from 'meteor/meteor';

Meteor.publish('orders', function() {
   // return Orders.find();
    return Orders.find({

                $and: [
                    { owner: this.userId },
                    { owner: { $exists: true } }
                ]
    });
});
开发者ID:ayush2016,项目名称:meteor1.3.2.4-angular2.0-olog,代码行数:13,代码来源:orders.ts

示例4: function

import {Meteor} from 'meteor/meteor';
import {Users} from './../../collections/users';
import {Counts} from 'meteor/tmeasday:publish-counts';
import * as Helpers from "./../../lib/helpers";

Meteor.publish("users.all", function(options: Object) {
    Counts.publish(this, "users.total", Users.find({}), { noReady: true });
    let secure = {
        fields: {
            "emails.address": 1,
            "createdAt": 1,
            "profile": 1
        }
    }
    options = Helpers.mergeOptions(options, secure);
    return Users.find({}, options);
});

Meteor.publish("users.detail", function(id: string) {
    return Users.find({ _id: id });
});
开发者ID:euclid1990,项目名称:fruit,代码行数:21,代码来源:user.component.ts

示例5: function

import {Meteor} from 'meteor/meteor';
import {GamificationGrid, GamificationRecords} from './collection';


Meteor.publish('gamification.records', function () {
    console.log('publishing records')
    return GamificationRecords.find({
        user_id: this.userId
    });
});

Meteor.publish('gamification.grid', function() {
    console.log('publishing grid')
    return GamificationGrid.find({
        user_id: this.userId
    });
});
开发者ID:kucharskimaciej,项目名称:bullet-journal,代码行数:17,代码来源:publish.ts

示例6:

import { Meteor } from 'meteor/meteor';

Meteor.publish('users', () => {
  return Meteor.users.find({}, {
    fields: {
      username: 1,
      profile: 1
    }
  });
});
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:10,代码来源:users.ts

示例7: function

import { Activity } from '../../../both/collections/activity.collection';
import { Meteor } from 'meteor/meteor';

Meteor.publish("activity", function() {
  return Activity.find({public:true});
});
开发者ID:michaelb-01,项目名称:pipe,代码行数:6,代码来源:activity.ts

示例8: tasksPublication

import {Tasks} from '../collections/tasks';
import {Meteor} from 'meteor/meteor';


  Meteor.publish('tasks', function tasksPublication() {
  return Tasks.find({owner: this.userId}); // find only user tasks
});



Meteor.publish('task', function(taskId: string) {
  return Tasks.find(
    {
      $and: [{  // find with given task id
          '_id': {
            $eq: taskId
          }
        }, { // find only if the owner access the task
          'owner': this.userId
        }, ],
      }
);

});
开发者ID:LIOSK-ORG,项目名称:todo-app,代码行数:24,代码来源:tasks.ts

示例9: function

import { Meteor } from 'meteor/meteor';
import { Counts } from 'meteor/tmeasday:publish-counts';

import { Poems } from '../../../both/collections/poems.collection';
import { PoemFilter } from '../../../both/filters/poem-filter';
import { Options } from '../../../both/filters/pagination';

Meteor.publish('poems', function(options: Options, filter?: PoemFilter) {
    // Publish total count
    Counts.publish(
        this,
        'numberOfPoems',
        Poems.collection.find(buildQuery.call(this, filter)),
        { noReady: true });

    // Return filtered poems
    return Poems.find(buildQuery.call(this, filter), options);
});

function buildQuery(filter?: PoemFilter): Object {
    const completeQuery = {
        // All users (even anonymous) can see completed poems
        isComplete: true
    };

    // Base query for poem permissions
    const baseQuery = this.userId
        ? { 
            $or: [completeQuery, {
                lastContributorId: {
                    // Logged in users can edit poems for which they're
开发者ID:babyshoes,项目名称:exquisite-corpus,代码行数:31,代码来源:poems.ts

示例10: function

import {Parties} from '../collections/parties';
import {Meteor} from 'meteor/meteor';

Meteor.publish('uninvited', function(partyId: string) {
    let party = Parties.findOne(partyId);

    if (!party)
        throw new Meteor.Error('404', 'No such party!');

    return Meteor.users.find({
        _id: {
            $nin: party.invited || [],
            $ne: this.userId
        }
    });
});
开发者ID:RichardHwang886,项目名称:socially16,代码行数:16,代码来源:users.ts


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