All Projects → peerlibrary → meteor-subscription-scope

peerlibrary / meteor-subscription-scope

Licence: BSD-3-Clause license
Scope queries on collections to subscriptions

Programming Languages

coffeescript
4710 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to meteor-subscription-scope

meteor-control-mergebox
Control mergebox of publish endpoints
Stars: ✭ 28 (+40%)
Mutual labels:  meteor, meteor-package, ddp
hypersubs
an upgraded version of Meteor subscribe, which helps optimize data and performance!
Stars: ✭ 13 (-35%)
Mutual labels:  meteor, meteor-package, ddp
Meteor-Cookies
🍪 Isomorphic bulletproof cookie functions for client and server
Stars: ✭ 41 (+105%)
Mutual labels:  meteor, meteor-package
Meteor Files
🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.
Stars: ✭ 1,033 (+5065%)
Mutual labels:  meteor, meteor-package
meteorman
A DDP client with GUI (The Postman for Meteor)
Stars: ✭ 51 (+155%)
Mutual labels:  meteor, ddp
Ostrio Analytics
📊 Visitor's analytics tracking code for ostr.io service
Stars: ✭ 9 (-55%)
Mutual labels:  meteor, meteor-package
Autocms
AutoCms is a simple solution for your Meteor.js app
Stars: ✭ 34 (+70%)
Mutual labels:  meteor, meteor-package
Meteor Comments Ui
Simple templates for comment functionality in your Meteor App
Stars: ✭ 78 (+290%)
Mutual labels:  meteor, meteor-package
Blaze
🔥 Meteor Blaze is a powerful library for creating live-updating user interfaces
Stars: ✭ 474 (+2270%)
Mutual labels:  meteor, meteor-package
react-meteor
Meteor Reactivity for your React application, inspired by react-native-meteor.
Stars: ✭ 16 (-20%)
Mutual labels:  meteor, ddp
Meteor Reactive Publish
Reactive publish endpoints
Stars: ✭ 123 (+515%)
Mutual labels:  meteor, meteor-package
Meteor Peerdb
Reactive database layer with references, generators, triggers, migrations, etc.
Stars: ✭ 128 (+540%)
Mutual labels:  meteor, meteor-package
Mongol Meteor Explore Minimongo Devtools
In-App MongoDB Editor for Meteor (Meteor DevTools)
Stars: ✭ 846 (+4130%)
Mutual labels:  meteor, meteor-package
Vue Meteor
🌠 Vue first-class integration in Meteor
Stars: ✭ 893 (+4365%)
Mutual labels:  meteor, meteor-package
Meteor-Template-helpers
Template helpers for Session, logical operations and debug
Stars: ✭ 35 (+75%)
Mutual labels:  meteor, meteor-package
Meteor Collection Helpers
⚙️ Meteor package that allows you to define helpers on your collections
Stars: ✭ 504 (+2420%)
Mutual labels:  meteor, meteor-package
Ostrio Neo4jdriver
Most advanced and efficient Neo4j REST API Driver, with support of https and GrapheneDB
Stars: ✭ 55 (+175%)
Mutual labels:  meteor, meteor-package
blaze-integration
Vue integration with Meteor's Blaze rendering engine.
Stars: ✭ 24 (+20%)
Mutual labels:  meteor, meteor-package
Meteor Blaze Components
Reusable components for Blaze
Stars: ✭ 361 (+1705%)
Mutual labels:  meteor, meteor-package
Meteor Easy Search
Easy-to-use search for Meteor with Blaze Components
Stars: ✭ 438 (+2090%)
Mutual labels:  meteor, meteor-package

subscription scope

This Meteor smart package allows scoping of queries on collections only to documents published by a subscription.

Adding this package to your Meteor application extends subscription's handle with scopeQuery and publish endpoint function's this is extended with this.enableScope().

Both client and server side.

Installation

meteor add peerlibrary:subscription-scope

API

The subscription handle returned from Meteor.subscribe contain a new method:

  • scopeQuery() – returns a query which limits collection's documents only to this subscription

Limiting is only done on documents, not on fields. If multiple publish endpoints publish different fields and you subscribe to them, all combined fields will still be available in all queries on the client side.

Inside the publish endpoint function this is extended with:

  • enableScope() – when enabled, for subscriptions to this publish endpoint, clients can use scopeQuery() to limit queries only to the subscription

Examples

If on the server side you have such publish endpoint (using MongoDB full-text search):

Meteor.publish('search-documents', function (search) {
  this.enableScope();

  var query = {$text: {$search: search}};
  query['score_' + this._subscriptionId] = {$meta: 'textScore'};

  return MyCollection.find(query);
});

Then you can on the client side subscribe to it and query only the documents returned from it:

var subscription = Meteor.subscribe('search-documents', 'foobar');

var sort = {}
sort['score_' + subscription.subscriptionId] = -1;

// Returns documents found on the server, sorted by the full-text score.
MyCollection.find(subscription.scopeQuery(), {sort: sort}).fetch();

// Returns count of documents found on the server authored by the current user.
MyCollection.find({$and: [subscription.scopeQuery(), {author: Meteor.userId()}]}).count();

Related projects

  • find-from-publication – uses an extra collection which means that there are some syncing issues between collections and much more data is send to the client for every document; in short, it is much more complicated solution to the simple but powerful approach used by this package
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].