Coder Social home page Coder Social logo

smartquery's Introduction

smartquery's People

Contributors

sachag avatar awei01 avatar arunoda avatar

Stargazers

David Barrat avatar Asad Dhamani avatar Mitar avatar  avatar  avatar Valentin Vichnal avatar Ben Lee-Cohen avatar Fabio Dias Rollo avatar Michael Nino Evensen avatar Christian Klaussner avatar Timon van Spronsen avatar Carlos Baraza avatar Max Savin avatar  avatar  avatar crapthings avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

arunoda awei01

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.

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.