Comments (9)
The find
function can return any falsy value (e.g., null
, undefined
, false
, etc) to short circuit. This effectively returns an empty set. You should never call this.ready()
or this.stop()
in find
functions.
For example:
Meteor.publishComposite("mypub", {
find: function() {
if (!this.user) {
return;
}
return MyCollection.find({ ... });
}
});
from meteor-publish-composite.
And what happens if you didn't return nothing? Can that cause problems?
from meteor-publish-composite.
Doing return;
is equivalent to return undefined;
which is perfectly fine.
from meteor-publish-composite.
Yeah, but what happens if a find doesn't return anything, like:
Find:{
If(bla){
return find...
}
}
from meteor-publish-composite.
Collection.find()
always returns a cursor, so that's fine. It doesn't matter if there are records in it or if it's empty.
from meteor-publish-composite.
Sorry, maybe I didn't explain it well but my question was what happens if bla (in this case) is false so collection.find is never fired. No return is called.
from meteor-publish-composite.
Ah, I see. That is also equivalent to return undefined;
so no problem.
from meteor-publish-composite.
ok thanks :)
from meteor-publish-composite.
In the native Meteor publish method, returning an empty cursor (i.e. []
) works (although this.stop()
is best practice) but doing this in publishComposite results in an error, it might be good to replicate this behavior? Although a return statement works. as described above.
from meteor-publish-composite.
Related Issues (20)
- Empty children HOT 4
- Publish loses reactivity after "load more" HOT 4
- Move to Meteor-Community-Packages organization? HOT 1
- All published records removed and re-added on subsequent subscriptions in 1.7.1 HOT 4
- Error: Doc not found in list HOT 1
- Join Data from Array of ID's HOT 1
- Exception in callback of async function: TypeError: Converting circular structure to JSON HOT 2
- Declaration file for TypeScript HOT 5
- [Question] How to use it together with middleware ? HOT 1
- Full compatibility with johanbrook:publication-collector
- children function won't rerun reactively
- Meteor collection hook direct not working
- Unset fields are not unset HOT 3
- Add TypeScript types HOT 1
- Remove underscore HOT 16
- Create GitHub action to run tests HOT 3
- Publications are ready before object merges are complete since 1.8.2 HOT 11
- Unhandled promise rejection HOT 3
- Error: Doc not found in list HOT 14
- TypeError: this.observeHandle.stop is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-publish-composite.