Problem
Entities are currently caller-supplied (e.g. "user/alice"), which means there is no way to create a new entity without knowing its identity upfront. Upserting an empty map produces nothing — but it should be a valid operation that allocates a new entity and returns it.
Solution
Entity IDs should be auto-generated from the id column of the facts table. Upserting any map — including an empty one — inserts at least one fact row, and the resulting entity is derived from that row's ID. The new entity is returned to the caller.
Implications
- Caller-supplied string entities like
"user/alice" are no longer valid. All entities are now system-generated.
- Existing tests that seed or assert against named entities (e.g.
"user/alice", "user/1") must be updated to work with auto-generated IDs.
- Test DB seeding logic needs to be adapted accordingly — seed calls should capture and thread through the returned entity rather than constructing one upfront.
Out of scope
Schemas or entity namespacing conventions. This project intentionally uses a free, grab-bag schema.
Problem
Entities are currently caller-supplied (e.g.
"user/alice"), which means there is no way to create a new entity without knowing its identity upfront. Upserting an empty map produces nothing — but it should be a valid operation that allocates a new entity and returns it.Solution
Entity IDs should be auto-generated from the
idcolumn of the facts table. Upserting any map — including an empty one — inserts at least one fact row, and the resulting entity is derived from that row's ID. The new entity is returned to the caller.Implications
"user/alice"are no longer valid. All entities are now system-generated."user/alice","user/1") must be updated to work with auto-generated IDs.Out of scope
Schemas or entity namespacing conventions. This project intentionally uses a free, grab-bag schema.