-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Model names sometime dont fit with how they are used, especially if there is pluralisation or the lack of.
e.g.
If we have a model called users which joins with userEmails (for example). And we write a request like...
dare.get({
table: 'userEmails',
fields: [
'email',
{
users: ['id', 'name'],
}
],
limit: 10,
});This would return an object like...
[
{
"email": "andrew@example.com",
"users": {
"id": 123,
"name": "Andrew"
}
}
]Unfortunately users is plural and isn't semantically correct, user (non-plural) would be best. Could there be a way to return a different name?
Approach
We currently alias models using the $ value to differentiate mulitple joins. This same semantics could be used to rename the models.
dare.get({
table: 'userEmails',
fields: [
'email',
{
users$user: ['id', 'name'],
}
]
});Now using the part after the $ as the name, i.e....
[
{
"email": "andrew@example.com",
"user": {
"id": 123,
"name": "Andrew"
}
}
]Does $ character make sense or should we use another syntax? Such as # which might be more fitting
Metadata
Metadata
Assignees
Labels
No labels