Modeling patterns
The MongoDB patterns that work the same in TeselaDB and when to use each one.
MongoDB's modeling patterns work the same in TeselaDB. Documents are the same, and so are the queries and indexes that read them.
How it works
These are the patterns used most, each with what it solves. None of them needs anything specific to TeselaDB. You apply
them with the same documents and the same commands you would use in MongoDB, from your application's driver or from
mongosh, without changing the model you already have when you move from one database to the other.
Computed values
Store a total or a count that is updated on write, so it is not computed on every read.
Bucketing
Group measurements of the same period in one document; time series do it for you.
Polymorphism
Documents of different shapes in the same collection, with a field that says their type.
Versioning
Store the schema version in each document and migrate on read or in the background.
Archiving
Move old documents to another collection so that the active one, the one your everyday queries read, stays small.
What it means for your application
Choose the pattern by how your application reads: one document should bring in a single read what the screen or the API needs, without you having to put together data from several collections every time someone opens that screen. Transactions across collections exist. Even so, a single write of one document is still the fastest.
Limits
A document cannot go over the maximum BSON size. A computed value has another limit. If many clients update it at once, it concentrates the load on that document's range.