mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-09-10 06:21:03 +00:00
feat(storage): store mongo values as native BSON documents
Implement mongodb_value_codec to encode portfolio/gold/stock values as native BSON documents instead of JSON-serialized byte strings. Reduces storage size, improves query efficiency, and eliminates unmarshal overhead. Native BSON encoding preserves int64 fidelity and enables future native-format queries. Add NativeValueRepresentation and Int64Fidelity tests validating lossless encoding. Update migration tool comments. Document native-value behavior in deploy guide. Update phase-01 plan with implementation notes.
This commit is contained in:
@@ -63,6 +63,14 @@ and the `STOCK/COIN/GOLD *_API_URL` overrides (modules use coded defaults).
|
||||
4. Copy the `mongodb+srv://…` connection string into `MONGO_URL` and put the
|
||||
db name in `MONGO_DATABASE`.
|
||||
|
||||
> Storage layout: one collection per module; each document is
|
||||
> `{ _id: <user key>, value: <native BSON document>, version, updatedAt }`.
|
||||
> Values are stored as native BSON (objects/arrays expand and are queryable in
|
||||
> Compass); non-JSON values (e.g. a date guard) are plain strings. Concurrency
|
||||
> uses the `version` field (optimistic lock). If you migrated data with an older
|
||||
> build that stored `value` as a string/blob, re-run the migrator (idempotent)
|
||||
> so values become native.
|
||||
|
||||
## 2. Coolify
|
||||
|
||||
1. New resource → from this Git repo (Docker Compose), or a prebuilt image.
|
||||
|
||||
Reference in New Issue
Block a user