Comments (6)
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.
@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.
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.
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.
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.
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)
- Package description identical to cottz-publish HOT 2
- seems broken HOT 1
- Help Plz: Filter/remove some documents from a this.cursor() - call? HOT 4
- one to many relationship HOT 10
- Crossbar problem! HOT 4
- How to get doc for relations fields? HOT 4
- Please example how to "return [cursor1, cursor2, cursor3];" HOT 2
- Trying this.listen example HOT 1
- Changing filters reactively HOT 3
- How handle array of objects in collection? HOT 2
- this.join unexpected behaviour HOT 7
- What are the advantages over reywood:publish-composite package HOT 5
- Add support for server minimongo HOT 3
- Is 'this.ready()' obligatory? HOT 4
- the parent doc is removed, the related children doc is not removed. HOT 5
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.
from cottz-publish-relations.