Giter Club home page Giter Club logo

Comments (5)

crapthings avatar crapthings commented on July 27, 2024 3

@thearabbit

collection.js

Posts = new Mongo.Collection('posts')

Meteor.isServer && Meteor.publish('posts', function() {
  // ReactiveAggregate(this, Posts, [{
  //   $lookup: {
  //     from: 'users',
  //     localField: 'userId',
  //     foreignField: '_id',
  //     as: 'user'
  //   }
  // }])

  return [Posts.find(), Users.find()]
})

client.js

Template.registerHelper('posts', function () {
  return Posts.find().map(post => {
    return _.extend(post, {
      user: Users.find(post.userId)
    })
  })
})

from meteor-reactive-aggregate.

thearabbit avatar thearabbit commented on July 27, 2024 1

Thanks for your reply.
Could example?

from meteor-reactive-aggregate.

psaelango avatar psaelango commented on July 27, 2024 1

@JcBernack - Is there any way to get reactivity of collection used by $lookup? I'm in a situation that I cannot use your above proposed solution that "publish other collections and join them on client side". Because of the huge amount of data in the other collection I cannot publish them. At the same time I need to aggregate with that collection data. Your suggestions would be very much appreciated

from meteor-reactive-aggregate.

JcBernack avatar JcBernack commented on July 27, 2024

This package observes changes in the given collection (Disbursement) and updates the aggregation. Changes to the collection used by $lookup will go unnoticed. Maybe you should push the other collections via separate publications and "join" on the client side.

from meteor-reactive-aggregate.

apathio avatar apathio commented on July 27, 2024

@crapthings

Thanks for posting this example. The reduction and flexibility of my code changes in relation to publications (publish composite, reactive join aggregations), coupled using react-komposer, simply exquisite. Fair amount of unbounded arrays requiring aggregations, so denormalizing was not a very good option (or really much of an option at all). This solved a ton of problems and helped me think of a couple of new ways to do things. Thanks again!

from meteor-reactive-aggregate.

Related Issues (20)

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.