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
When saving a collection of bookshelf objects the case-converter plugin will transform child objects destined for json/jsonb fields from camelCase into snake_case. It does not do this transformation when saving a single item outside a collection. This inconsistency is bad.
Example
The expectation is for the jsonb field user_account.security_access to have its data saved consistently (preferably without alteration of any kind).
Bookshelf definition
bookshelf = Bookshelf(knex)
bookshelf.plugin('processor')
bookshelf.plugin('pagination')
bookshelf.plugin('case-converter')
User = bookshelf.Model.extend({
tableName: 'user_account',
})
Users = bookshelf.Collection.extend({
model: User
})
Save operation for a single user
newUser:(props)=>{
const query = (new bs.User(props))
return query.save()
}
Save operation for multiple users
newUsers:(newUsers)=>{
return (new bs.Users(newUsers)).insert()
}
Example new user data structure when saving as a collection (just pluck one from this when saving as single item)
In the example above, the json properties nodeIds & groupIds are expected to be stored within the jsonb field as nodeIdsgroupIds.
Instead, they altered and stored as node_ids & group_ids within the jsonb field when saved from a collection, but not when saved as a single row insert.
The text was updated successfully, but these errors were encountered:
Introduction / Description
When saving a collection of bookshelf objects the
case-converter
plugin will transform child objects destined forjson
/jsonb
fields fromcamelCase
intosnake_case
. It does not do this transformation when saving a single item outside a collection. This inconsistency is bad.Example
The expectation is for the jsonb field
user_account.security_access
to have its data saved consistently (preferably without alteration of any kind).Bookshelf definition
Save operation for a single user
Save operation for multiple users
Example new user data structure when saving as a collection (just pluck one from this when saving as single item)
Expected / Actual behavior
In the example above, the json properties
nodeIds
&groupIds
are expected to be stored within the jsonb field asnodeIds
groupIds
.Instead, they altered and stored as
node_ids
&group_ids
within the jsonb field when saved from a collection, but not when saved as a single row insert.The text was updated successfully, but these errors were encountered: