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

Sam: Projection read model copies to MongoDB #114

Merged
merged 47 commits into from
Feb 9, 2022
Merged

Sam: Projection read model copies to MongoDB #114

merged 47 commits into from
Feb 9, 2022

Conversation

jakhog
Copy link
Contributor

@jakhog jakhog commented Feb 1, 2022

Summary

Introduces APIs to configure secondary storage for Projection read models for querying, as introduced in dolittle/Runtime#614 (requires Runtime v7.6.0). These changes makes it easy to query Projection read models by specifying that you want copies stored in MongoDB, and then use an IMongoCollection<> for that Projection as any other MongoDB collection. The Projection still operates normally and can be fetched from the Projection Store. Modifications of documents in the copied collections will affect the original Projection processing, but should be avoided as it could cause unexpected behaviour. The collections are automatically created and dropped as needed by the Runtime when Projections are created or changed.

There is currently no mechanism for detecting multiple projections copied to the same collection, so be aware of possible strange behaviour if you have multiple Projections with the same name.

Added

  • The @copyToMongoDB(...) decorator that enables read model copies for a Projection class to MongoDB. The default collection name is the same as the class name. The decorator accepts an argument to override the collection name.
  • The @convertToMongoDB(conversion) decorator to specify a BSON conversion to apply when copying the Projection read model to a MongoDB collection.
  • A .copyToMongoDB(...) method on the Projection builder for enabling read model copies for Projections created using the builder API. This method accepts a callback that you can use to set the collection name and conversions for the read model copies.
  • Extension method Db.collection(readModelType, settings?) to get a collection using the name of the read model or the collection specified in the @copyToMongoDB(collection) decorator.

@jakhog jakhog added the minor label Feb 1, 2022
@jakhog jakhog marked this pull request as ready for review February 9, 2022 12:51
@jakhog jakhog merged commit 4a2e48c into master Feb 9, 2022
@jakhog jakhog deleted the 22.2.0-sam branch February 9, 2022 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants