Special collections
Views, capped collections, time series and clustered collections.
Besides the normal collection, TeselaDB has MongoDB's other collection types.
Views
A view is a named aggregation you query as a collection:
JavaScript
db.createView("paidOrders", "orders", [{ $match: { status: "paid" } }]);Capped collections
A capped collection keeps a maximum size and deletes the oldest documents when it fills. It takes a range of its own that never splits or merges, and supports cursors that follow the tail:
JavaScript
db.createCollection("log", { capped: true, size: 64 * 1024 * 1024 });Time series
Measurements are stored grouped in buckets by time and metadata; queries return the individual measurements:
JavaScript
db.createCollection("readings", {
timeseries: { timeField: "ts", metaField: "sensor", granularity: "minutes" },
});Clustered collections
A clustered collection orders its documents by _id and can delete them when they expire:
JavaScript
db.createCollection("sessions", { clusteredIndex: { key: { _id: 1 }, unique: true }, expireAfterSeconds: 86400 });A collection cannot be capped and clustered at the same time.