Practical Guidance¶
If you need to choose quickly:
- declare module-owned models from
democrai.sdk.database.Base - use
add(...)to create rows - use
get(...)for one id-addressable row - use
list(...)orall(...)for multiple filtered rows - use
update(...)for one scoped row mutation - use
delete(...)for one scoped row removal - use
sdk.modelsinstead when the data is platform-owned rather than module-owned
Practical Rules¶
- Always declare module-owned ORM models from
democrai.sdk.database.Base. - Do not use
sdk.databasefor core-owned tables or platform registries. - Rely on the datastore for module validation and scope enforcement instead of reimplementing those checks manually.
- Do not manually set
user_idandorganization_idon create unless you have a very specific advanced reason and understand the overwrite behavior. - Treat
Nonefromget(...)andupdate(...), andFalsefromdelete(...), as normal scoped outcomes rather than proof of a runtime bug. - Prefer the simplest CRUD method that matches the job before reaching for lower-level datastore behavior.