Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 743de17

Browse files
author
Dekel Barzilay
committed
Changed params operator $atomic to atomic
1 parent 8b97953 commit 743de17

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Note that all this eager related options are optional.
246246
[`transaction`](https://vincit.github.io/objection.js/api/objection/#transaction)
247247
documentation.
248248

249-
- **`$atomic`** - when `true` ensure that multi create or graph insert/upsert success or fail all at once. Under the hood, automaticaly create a transaction and commit on success or rollback on partial or total failure. __Ignored__ if you added your own `transaction` object in params.
249+
- **`atomic`** - when `true` ensure that multi create or graph insert/upsert success or fail all at once. Under the hood, automaticaly create a transaction and commit on success or rollback on partial or total failure. __Ignored__ if you added your own `transaction` object in params.
250250

251251
- **`mergeAllowEager`** - Will merge the given expression to the existing expression from the `allowEager` service option.
252252
See [`allowGraph`](https://vincit.github.io/objection.js/api/query-builder/eager-methods.html#allowgraph)

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ class Service extends AdapterService {
315315
}
316316

317317
async _createTransaction (params) {
318-
if (!params.transaction && params.$atomic) {
319-
delete params.$atomic;
318+
if (!params.transaction && params.atomic) {
319+
delete params.atomic;
320320
params.transaction = params.transaction || {};
321321
params.transaction.trx = await this.Model.startTransaction();
322322
return params.transaction;

test/index.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ describe('Feathers Objection Service', () => {
18481848
});
18491849

18501850
it('works with atomic', () => {
1851-
return people.create({ name: 'Rollback' }, { transaction, $atomic: true }).then(() => {
1851+
return people.create({ name: 'Rollback' }, { transaction, atomic: true }).then(() => {
18521852
expect(transaction.trx.isCompleted()).to.equal(false); // Atomic must be ignored and transaction still running
18531853
return transaction.trx.rollback().then(() => {
18541854
return people.find({ query: { name: 'Rollback' } }).then((data) => {
@@ -1887,7 +1887,7 @@ describe('Feathers Objection Service', () => {
18871887

18881888
it('Rollback on sub insert failure', () => {
18891889
// Dan Davis already exists
1890-
return companies.create({ name: 'Compaq', clients: [{ name: 'Dan Davis' }] }, { $atomic: true }).catch((error) => {
1890+
return companies.create({ name: 'Compaq', clients: [{ name: 'Dan Davis' }] }, { atomic: true }).catch((error) => {
18911891
expect(error instanceof errors.GeneralError).to.be.ok;
18921892
expect(error.message).to.match(/SQLITE_CONSTRAINT: UNIQUE/);
18931893
return companies.find({ query: { name: 'Compaq', $eager: 'clients' } }).then(
@@ -1899,7 +1899,7 @@ describe('Feathers Objection Service', () => {
18991899

19001900
it('Rollback on multi insert failure', () => {
19011901
// Google already exists
1902-
return companies.create([{ name: 'Google' }, { name: 'Compaq' }], { $atomic: true }).catch((error) => {
1902+
return companies.create([{ name: 'Google' }, { name: 'Compaq' }], { atomic: true }).catch((error) => {
19031903
expect(error instanceof errors.GeneralError).to.be.ok;
19041904
expect(error.message).to.match(/SQLITE_CONSTRAINT: UNIQUE/);
19051905
return companies.find({ query: { name: 'Compaq' } }).then(
@@ -1925,7 +1925,7 @@ describe('Feathers Objection Service', () => {
19251925
name: 'Kirk Maelström'
19261926
}
19271927
]
1928-
}, { $atomic: true }).catch((error) => {
1928+
}, { atomic: true }).catch((error) => {
19291929
expect(error instanceof errors.GeneralError).to.be.ok;
19301930
expect(error.message).to.match(/SQLITE_CONSTRAINT: UNIQUE/);
19311931
return companies.find({ query: { name: 'Google', $eager: 'clients' } }).then(
@@ -1954,7 +1954,7 @@ describe('Feathers Objection Service', () => {
19541954
name: 'Kirk Maelström'
19551955
}
19561956
]
1957-
}, { $atomic: true }).catch((error) => {
1957+
}, { atomic: true }).catch((error) => {
19581958
expect(error instanceof UniqueViolationError).to.be.ok;
19591959
expect(error.message).to.match(/SQLITE_CONSTRAINT: UNIQUE/);
19601960
return companies.find({ query: { name: 'Google', $eager: 'clients' } }).then(
@@ -1983,7 +1983,7 @@ describe('Feathers Objection Service', () => {
19831983
name: 'Kirk Maelström'
19841984
}
19851985
]
1986-
}, { $atomic: true }).catch((error) => {
1986+
}, { atomic: true }).catch((error) => {
19871987
expect(error instanceof UniqueViolationError).to.be.ok;
19881988
expect(error.message).to.match(/SQLITE_CONSTRAINT: UNIQUE/);
19891989
return companies.find({ query: { name: 'Google', $eager: 'clients' } }).then(

0 commit comments

Comments
 (0)