Git Product home page Git Product logo

find-from-publication's People

Contributors

arichter83 avatar csillag avatar dandv avatar dburles avatar sebakerckhof avatar tmeasday avatar zol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

find-from-publication's Issues

observe doesn't work when using findFromPublication()

findFromPublication works great for me when I use it from within a template but when I try using the observe function on the cursor I don't hit the added code when adding new documents to the db (on initial page load the added function does happen for all items that are already in the collection, but afterwards it doesn't).

// client code
Meteor.subscribe('allPosts', {
    onReady: function() {      
      Posts.findFromPublication('allPosts', {}).observe({      
        added: function(doc) {          
          // this line isn't hit when adding new documents
        }
      });          
    },
    onError: function() {
      console.log("error");      
    }
  });  

findFromPublication is not a function

ive followed the instructions on read me but I've got error on client side

MyModel.findFromPublication is not a function

any hints on this problem?

Searching for a an object with a matching field does not seem to work with this

Maybe I am missing something. Here is the use case:

Meteor.users.findFromPublication({'emails.address': email})

will find any user who has a matching email in his emails (array of objects with field address containing the email). It works on the server. In my case it finds one matching user.

But when I call FindFromPublication on the client, it returns 0 objects.

All the other queries with findFromP work but not this one.

I should add that I am calling subscribe with a query and a sort. Not just a simple subscription.

Subscription leading to Error: $or/$and/$nor entries need to be full objects

FindFromPublication.publish('host.hostevents', function (username) {
  // var userId = this.userId,
  let host = Meteor.users.find({username: username});
  if(host){
      let data = [
          Meteor.users.find({username: username,
            $or: [ 
              {type: "H"},
              {type: "T"},
              {type: "O"}
            ]})         
        ]; 

    if (data) {
      return data;
    }
  }
  return this.ready();
});

the subscription above leads to error below,

Exception in template helper: Error: $or/$and/$nor entries need to be full objects
    at selectors.map.subSelector (http://localhost:3000/packages/minimongo.js?hash=69b3295a15785e800af1d79e2fca46b6ec29aac0:617:13)
    at Array.map (<anonymous>)
    at compileArrayOfDocumentSelectors (http://localhost:3000/packages/minimongo.js?hash=69b3295a15785e800af1d79e2fca46b6ec29aac0:615:20)

while a normal meteor.publish doesn't give errors how ever, i get the verlap which is why I am trying to use this package.
What could be wrong?

Frequent "Match error: Failed Match.OneOf or Match.Optional validation" messages on server side

I am getting a lot of these types of messages on the Meteor server side terminal output.

I20151002-18:48:30.810(0)? Exception from sub recentPosts id K42kw2vAkK5wxawTv Error: Match error: Failed Match.OneOf or Match.Optional validation
I20151002-18:48:30.811(0)?     at checkSubtree (packages/check/match.js:244:1)
I20151002-18:48:30.811(0)?     at check (packages/check/match.js:32:1)
I20151002-18:48:30.811(0)?     at [object Object]._.extend._getFindOptions (packages/mongo/collection.js:244:1)
I20151002-18:48:30.811(0)?     at [object Object]._.extend.find (packages/mongo/collection.js:280:1)
I20151002-18:48:30.812(0)?     at [object Object].<anonymous> (server/publications.js:459:21)
I20151002-18:48:30.812(0)?     at [object Object]._handler (packages/percolate_find-from-publication/packages/percolate_find-from-publication.js:49:1)
I20151002-18:48:30.812(0)?     at maybeAuditArgumentChecks (livedata_server.js:1692:12)
I20151002-18:48:30.812(0)?     at [object Object]._.extend._runHandler (livedata_server.js:1023:17)
I20151002-18:48:30.813(0)?     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
I20151002-18:48:30.813(0)?     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
I20151002-18:48:30.813(0)? Sanitized and reported to the client as: Match failed [400]

How should investigate this problem (if it is a problem)?

Here is the publish function:

 FindFromPublication.publish('recentPosts', function (limit) {
    var username = getUsername(this.userId);
    return Articles.find({
      author: username
    }, {
      sort: {
        createdAt: -1
      },
      limit: limit
    });
  });

Could I return custom data from calculate many collections?

I want to generate report that calculate many collections and then return it like this:

// Server
FindFromPublication.publish('allPosts', function() {
   var data = [];

   // do something with many collections

    return data;
  });

// client
Meteor.subscribe('allPosts');

var postsCursor = Posts.findFromPublication('allPosts');

Filtering by subscription name doesn't work when using `_id` in a selector

Here is my case:
I am subscribed to my own user from db.users collection.
Then I am subscribing to the list of users on some page filtered by user id's, i.e. something like:

db.users.find({_id: {$in: ['myuserid', 'otheruserid1', 'otheruserid2', ...]}}, {skip: 10})

after this

db.users.findFromPublication('mysub', {_id: {$in: ['myuserid', 'otheruserid1', 'otheruserid2', ...]}})

always includes my user even though it is not received from mysub, but is subscribed to separately. When I remove the _id filter, i.e. doing just

db.users.findFromPublication('mysub', {})

it returns LESS elements (same list excluding me) even though removing a filter is not expected to exclude any results.

Error: $or/$and/$nor entries need to be full objects

With the update I get the following error:

Error: $or/$and/$nor entries need to be full objects meteor.js:1048:11
compileArrayOfDocumentSelectors/<@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:617:13
compileArrayOfDocumentSelectors@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:615:10
$and@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:328:32
compileDocumentSelector/docMatchers<@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:646:14
compileDocumentSelector@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:635:23
_compileSelector@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:4013:12
Matcher@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:3944:24
Cursor@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:1430:20
find@http://localhost:3000/packages/minimongo.js?hash=04456b5cba2949764c60f0809ae5cf78590bcd67:2028:12
find@http://localhost:3000/packages/mongo.js?hash=f70e3bfe4cc05b9ab7dc360ca483fa530d45ebc6:425:12
@http://localhost:3000/packages/percolate_find-from-publication.js?hash=8a2ba684b8f9877db688f55ca08218d2a901b192:86:12
Homepage.js/exports.default<@http://localhost:3000/app/app.js?hash=687575af54a94b99c47519790b82a33020be7078:1551:18

Using the following queries:

  FindFromPublication.publish('questions.hottest', function() {
    var claps = Claps.aggregate([
      { $match: { createdAt: {$gt: new Date((new Date() as any) - 24 * 60 * 60 * 1000) } } },
      { $group: { _id: "$questionId", total: { $sum: "$count" }}},
      { $sort: { total: -1 } },
      { $limit: 3 }
    ]);
    
    return Questions.find({_id: {$in: claps.map((clap) => { return clap._id })}}, {fields: Questions.publicFields});
  });

  FindFromPublication.publish('questions.myactive', function() {
    var claps = Claps.aggregate([
      { $match: { userId: Meteor.userId() } },
      { $group: { _id: "$questionId", latest: { $max: "$createdAt" }}},
      { $sort: { latest: -1 } },
      { $limit: 3 }
    ]);
    
    return Questions.find({_id: {$in: claps.map((clap) => { return clap._id })}}, {fields: Questions.publicFields});
  });

FYI, I wil investigate it later...

Meteor.users.findFromPublication gets only the current user if the current user is updated since 1.3

I have a non-trivial application at the moment, so it's going to be a bit difficult to extract the part of code that is causing the issue.

However, I am using "alanning:roles" and I found that when data on the current user gets updated the subscription will only have the current user. However, it's not consistent as of yet. I am in the midst of putting in console.log statements in your code to see what may be causing the problem.

The problem started manifesting in Meteor 1.3.

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.