MemoryCrate
Stores items in a Json[] array. No persistence — data is lost when the process exits. Useful for testing, prototyping, and development.
import crate.collection.memory;
auto products = new MemoryCrate!Product;router.crateSetup!RestApi.add(products);With config:
auto config = CrateConfig!Product();config.deleteItem = false;
auto products = new MemoryCrate!Product(config);How It Works
Section titled “How It Works”- Storage:
Json[]array in memory - ID generation: Auto-generates
BsonObjectIDstrings on insert - Queries: Uses
BsonQueryBuilderinternally, so query syntax is identical toMongoCrate - Filtering:
itemFilter()evaluates Bson query patterns against in-memory items - No persistence: Data exists only for the lifetime of the process
Query Support
Section titled “Query Support”MemoryCrate supports the full IQuery interface — where, sort, limit, skip, distinct, searchText, and field projections. The BsonQueryBuilder ensures the same query syntax works whether you’re using Memory or Mongo as the backend, making it easy to swap between them.
When to Use
Section titled “When to Use”- Unit and integration tests
- Rapid prototyping
- Development without a database
- Small datasets that fit in memory