You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a configurable macro to perform crud operations. If a config file exists it will use to fill the missing information for each model, why? Because it is most likely that you use different structs to execute queries over the same table.
{
"users": {
"primary_key": "id",
"relations": {
"posts": {
"post_id": "id",
},
},
// Not sure if this is the right name, but this will work as a field required for each operation, no matter what, useful for multitenancy "constraints": {
"tenant_id"
},
}
}
#[derive(Record)]// You can pass the actions selectable, insertable, updatable or deletable, the default value is all of them#[record(table = "users")]structUser{firstname:String,lastname:String,}let user = User{ .. };User::insert(&pool, user, tenant_id);
user.update(&pool, tenant_id);
user.delete(&pool, tenant_id);User::by_id(&pool,5, tenant_id);
Records are not intended to use for other complex queries, the idea is to use it as a helper to reduce boilerplate of common straightforward queries.
Some considerations, it is annoying to pass the tenant over and over again, so there can be a way to apply an extension to axum that contains the pool and current tenant, so inside the crud functions it will retrieve the tenant (if any) from the extension, this will reduce even further the boilerplate.
The text was updated successfully, but these errors were encountered:
Add a configurable macro to perform crud operations. If a config file exists it will use to fill the missing information for each model, why? Because it is most likely that you use different structs to execute queries over the same table.
Records are not intended to use for other complex queries, the idea is to use it as a helper to reduce boilerplate of common straightforward queries.
Some considerations, it is annoying to pass the tenant over and over again, so there can be a way to apply an extension to axum that contains the pool and current tenant, so inside the crud functions it will retrieve the tenant (if any) from the extension, this will reduce even further the boilerplate.
The text was updated successfully, but these errors were encountered: