Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch tag frequency / sorted list from server #231

Open
neopostmodern opened this issue Dec 15, 2023 · 1 comment
Open

Fetch tag frequency / sorted list from server #231

neopostmodern opened this issue Dec 15, 2023 · 1 comment

Comments

@neopostmodern
Copy link
Owner

This would speed up the crazy slow cache-rebuilding on cold devices, plus it could easily be refreshed irregularly.

@neopostmodern
Copy link
Owner Author

neopostmodern commented Apr 6, 2024

Sample code

db.tags.aggregate([
  { 
    $lookup: { 
      from: "notes", 
      localField: "_id", 
      foreignField: "tags", 
      let: { tagId: "$_id" }, 
      pipeline: [ { $count: "count" } ], 
      as: "noteCount" 
   } 
  }, 
  { $unwind: "$noteCount" } 
])

keep performance in balance?

db.tags.aggregate([` { $lookup: { from: "notes", localField: "_id", foreignField: "tags", let: { tagId: "$_id" }, pipeline: [{ $count: "count" }], as: "noteCount" } }, { $unwind: '$noteCount' }, { $addFields: { noteCount: '$noteCount.count' } }] ).explain("executionStats")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant