Git Product home page Git Product logo

Comments (6)

lfades avatar lfades commented on July 28, 2024 1
Meteor.publishRelations('clicks', function (country) {
  let users = this.join(Meteor.users),
  campaings = this.join(Campaings)

  this.cursor(Clicks.find({country}), function (id, doc) {
    users.push(doc.agent_id)
    campaings.push(doc.campaing_id)
  })

  users.send()
  campaings.send()

  return this.ready()
})

Explanation: If you have 100 clicks, will make a query to find 100 clicks, then keep all _ids and will consult in other collections. in total they would be three queries to the database and should be quick and effective

from cottz-publish-relations.

lfades avatar lfades commented on July 28, 2024 1

@ralphievolt I didn't quite understand what you're trying to say, but I'm going to assume that you want to display the name of a document in a different collection based on the id.

function getName (_id) {
  return collection.find({_id}).fetch()[0].name;
}

{this.props.subCatList.map((item, index) => (
  <tr key={index}>
    <td>{item.subcategory}</td>       

    <td>{item.categoryID}</td>
     
    <td>{item.created.by}</td>
    <td>
      <button className="ui blue basic mini button" value={getName(_id)} onClick={this._handleItemClick(event)} >{item.status}</button>
    </td>
  </tr>
)}

Remember that although the package does joins, it does not mix the documents.

from cottz-publish-relations.

ickyrr avatar ickyrr commented on July 28, 2024

Thanks for responding right away @goluis , just a quick question, would this also help the devs out when building a project which handles large amount of data?

from cottz-publish-relations.

lfades avatar lfades commented on July 28, 2024

yes, that was one of the reasons why I create the package, needed an easy way to create complex queries on the server for my application

from cottz-publish-relations.

ralphievolt avatar ralphievolt commented on July 28, 2024

@goluis @ickyrr

I followed the above example to join multiple collections which seems to work... In my client I can see two collections which I can use..

My problem is how to show the name instead of an Id..here's my code in REACT

{ this.props.subCatList.map((item,index) => (
      <tr key={index}>
             <td>{item.subcategory}</td>       
        
             <td>{item.categoryID}</td>
             
             <td>{item.created.by}</td>
             <td>
                  <button className="ui blue basic mini button" value={item._id} onClick={this._handleItemClick(event)} >{item.status}</button>
             </td>
       </tr>
    )
)}

Am I missing something here? Am I supposed to receive only one subscriptions with my categoryName instead of categoryID?

from cottz-publish-relations.

ralphievolt avatar ralphievolt commented on July 28, 2024

i wanted to see the category name instead of <td>{item.categoryID}</td>

anyway, i'll try creating a new component based on your answer and see if I can get it working

from cottz-publish-relations.

Related Issues (16)

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.