Changelog
[0.27.21] 2024-10-28
Added upsert
method:
The upsert
method allows inserting or updating an entity in a single operation. If an entity matching the where
condition is found, it is updated; otherwise, a new entity is created. This can be used for a single entity or for batch operations with an array of options.
Example:
// Single entity upsert
await taskRepo.upsert({
where: { title: 'task a' },
set: { completed: true },
})
// Batch upsert
await taskRepo.upsert([
{ where: { title: 'task a' }, set: { completed: true } },
{ where: { title: 'task b' }, set: { completed: true } },
])
Now you can get data and aggregate info with a single request using the query
method:
const result = await repo
.query({
where: { completed: false },
pageSize: 50,
aggregates: {
sum: ['salary'],
average: ['age'],
},
})
.paginator()
// Accessing the items from the first page
console.table(result.items)
// Accessing the aggregation results
console.log(result.aggregates.salary.sum) // Total salary sum
Added TestApiDataProvider
to use in unit tests that test api rules. see tutorial
Fixed that values that are not included will not exist in the resulting object (previously they existed with value undefined)
Fixed that relations that were not included, will not be enumerable in the resulting object (previously they were only set to undefined)
Fixed serverExpression
to run whenever we're not using a proxy
data provider (for example RestDataProvider)
Fixed issue with updateMany
where the set
had ValueListType
or relation.
Fixed issue when updating relation id and relation in the same update, the last one will win
Fixed makeTitle to handle all caps text
Added experimental api for sqlRelations & sqlRelationsFilter - see Sql Relations