smartquery's Introduction
smartquery's People
smartquery's Issues
[FR] Allow functions that return arrays for `fields` rule
If you allow functions, it would be further possible to create fine grained rules that reveal subsets of documents.
For example, we may allow:
- everyone to subscribe to all users' user names,
- admins to subscribe to emails as well
- current user to subscribe to the complete user document
Problem passing regex in SmartQuery.create() on client
I just ran into an issue trying to search by regex:
// inside a helper
var cursor = Posts.find({ title: /^foo/i });
return SmartQuery.create('posts', cursor);
I'm guessing Meteor.subscribe can't pass the regex object to the server properly.
Do we need to stop() the subscription?
Just wondering, is there a potential for memory leaking? This is probably more a question as to how the meteor core works, but if we continue Meteor.subscribe()
from within a helper method, when that helper method is invalided what happens to the previous subscription? Do they just pile up in browser memory?
SmartQuery.create() using cursor having a .sort creates invalid sort object
If I pass a sort
option to my cursor like this:
SmartQuery.create('foo', Foos.find({}, { sort: { bar: 1 } });
I get Exception from sub SmartQuery_Clients id NTTPFDu8hgvKQQxiy MongoError: Can't canonicalize query: BadValue bad sort specification
.
This line if (cursor.sorter !== null) { options.sort = cursor.sorter; }
converts the sort option into MiniMongo.Sorter
object which is unusable on the server side.
Problem with unlimitedOptions?
In the following lines: https://github.com/SachaG/smartquery/blob/master/lib/publications.js#L62-L64
Shouldn't the limit
be deleted instead of options
like:
var unlimitedOptions = _.clone(options);
delete unlimitedOptions.limit;
Counts.publish(this, id, collection.find(validSelector, unlimitedOptions));
Then again, couldn't it be simplified like this:
Counts.publish(this, id, collection.find(validSelector));
Handling single record?
Not sure if this is out of the scope of the package, but how would you handle getting single documents? It doesn't make sense to return the entire object from SmartQuery.create
that contains helpers like hasMore
, count
, etc.
[Question] Allow developer to select collections?
Correct me if I'm wrong, but, doesn't Meteor.startup
cycle through all of the collections and create publications for them?
Would it make sense to have a SmartQuery.publish
method that accepts an array of collections for which you want to create the publications?
Just wondering. Thanks.
[Discussion] Why would I *not* want to use this?
This seems so magical and straightforward, why would I not want to use this for all my mongo cursor publications?
Are there any potential downsides or shortcomings that one could think of?
Few thoughts; one would want
- to combine cursors into a single publication for performance
- joins so prefer something like reywood:publish-composite
- to use observe/observeChanges, transform to modify documents on the fly
[Question] Define cursor in shared client/server file?
@tmeasday suggested defining the cursor in a shared file rather than passing it from the client, to avoid security issues.
So instead of:
Template.posts.helpers({
posts: function () {
var cursor = Posts.find({}, {limit: Session.get("postsLimit")});
return SmartQuery.create("posts", cursor);
}
}
We would have on the client/server:
SmartQuery.create({
name: "posts",
selector: {},
options: {
limit: ...
}
});
(Except we need a way to pass parameters, too)
And then on the client:
Template.posts.helpers({
posts: function () {
return SmartQuery.use("posts", Session.get("postsLimit"));
}
}
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.