mongodb - How to query username from userId in a collection in Meteor? -


i trying implement basic search bar functionality in app.

i have bunch of articles, , has owner. specified userid in user parameter of each article.

right can search keywords within article, title, , date. want able query username of author of article, have userid available me...

var keyword  = session.get("search-query"); var query = new regexp( keyword, 'i' );  var results = articles.find( { $or: [{'user': query}, // searching userid of author!                             {'title': query},                             {'articletext': query},                             {'datetime': query}] } ); return {results: results}; 

i'm not sure how this...

welcome non-relational databases! you're coming rdbms environment expect joins. there none. store username in article belongs to, yes, if user change username, you'll need loop through collection , update username _id matches.

please here mongo strategies (this isn't meteor-specific @ all): http://docs.mongodb.org/manual/core/data-modeling/

ps: if eye haemorrhaging whenever @ schema-which-actually-really-isn't-one, can still give https://github.com/erundook/meteor-publish-with-relations go - note under hood it's going 'worse' (have @ mongo opslog). publish relations there convenience , ease of programming, not performance.

good luck!


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -