CsvCrate
Reads and writes items from a CSV file. Each row is a record, with the first row as the header.
import crate.collection.csv;
auto products = new CsvCrate!Product("data/products.csv");router.crateSetup!RestApi.add(products);How It Works
Section titled “How It Works”- Storage: Flat CSV file on disk
- Header: First line defines field names
- ID: Uses
_idfield if present, otherwise line number - Reads: Parses the entire file on each query
- Writes: Rewrites the file on insert/update/delete
Nested Fields
Section titled “Nested Fields”Supports dot-notation for nested structs:
_id,name,position.type,position.lat,position.lng1,Headquarters,Point,52.5,13.4Maps to:
{ "_id": "1", "name": "Headquarters", "position": { "type": "Point", "lat": 52.5, "lng": 13.4 }}When to Use
Section titled “When to Use”- Importing/exporting flat data
- Small, rarely-written datasets
- Quick prototyping without a database
Not suited for concurrent writes or large datasets — the entire file is read and rewritten on every operation.