Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Schema Views (aka schema defined aggregations) #83

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daedalus28
Copy link
Member

@daedalus28 daedalus28 commented Jul 10, 2020

This would add support for arbitrary aggs defined as part of schemas. It's effectively the same as creating a non-materialized view, but we've discussed this enough times that it makes sense to have this PR open as a discussion point.

You'd use it like this, which shows an example of performing a lookup before running any other filters:

let schema = {
  name: 'joinedRequests',
  mongo: {
    collection: 'quoteRequest',
    aggs: [{ $lookup: { from: 'organization', /*...*/ } }],
  },
}

An alternative to this might be explicit support for $lookup only, because we can optimize better than Mongo could natively. The idea would be to only run the lookup only if needed and as late as possible - up front if it's needed for filters, after the filters if it's only needed for results, and not at all if the results don't need it. We'd likely add an API for node types to specify their lookup dependencies so we don't resort to something naive like a regex/string includes on a stringified Mongo blob 😂

@decrapifier
Copy link
Contributor

Fails
🚫 The version was not updated. Please update the version.
🚫 The changelog has not been updated. Please update the changelog.
🚫 Please assign someone to merge this PR, and optionally include people who should review.
Warnings
⚠️ The README has not been updated. Please update the README.
⚠️

Branch being merged does not follow Git Flow

⚠️ You should add at least 1 more reviewer to the PR
Messages
📖 Could not find any browser results.

Generated by 🚫 dangerJS against 40b0d7a

@ccalbaugh
Copy link
Contributor

I like this idea and I think we could definitely do this with the updated node API you mentioned. The downside seems to be that this is applied at all times, when the solution in #91 is more flexible on when it can be implemented. That being said, if we can find a way to intelligently apply the lookups based on node types/filter composition this seems like the more straightforward solution.

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

Successfully merging this pull request may close these issues.

3 participants