-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
124144 | ||
122840 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
export default async function f(db: any){ | ||
import { DBHandlerServer } from "../dist/DboBuilder"; | ||
import { strict as assert } from 'assert'; | ||
|
||
export default async function f(db: DBHandlerServer){ | ||
|
||
/** Self reference recursion bug */ | ||
await db.rec.findOne({ id: 1 }, { select: { "*": 1, rec_ref: "*" } }) | ||
await db.rec.findOne!({ id: 1 }, { select: { "*": 1, rec_ref: "*" } }) | ||
|
||
const whereStatement = await db.rec.find!({ id: 1 }, undefined, undefined, undefined, { returnQuery: "where-condition" }); | ||
|
||
assert.equal(whereStatement, `"id" = 1`); | ||
|
||
/* Transaction example */ | ||
await db.tx(async t => { | ||
await t.items.insert({ name: "tx_" }); | ||
const expect1 = await t.items.count({ name: "tx_" }); | ||
const expect0 = await db.items.count({ name: "tx_" }); | ||
await db.tx!(async t => { | ||
await t.items.insert!({ name: "tx_" }); | ||
const expect1 = await t.items.count!({ name: "tx_" }); | ||
const expect0 = await db.items.count!({ name: "tx_" }); | ||
if(expect0 !== 0 || expect1 !== 1) throw "db.tx failed"; | ||
|
||
//throw "err"; // Any errors will revert all data-changing commands using the transaction object ( t ) | ||
}); | ||
const expect1 = await db.items.count({ name: "tx_" }); | ||
const expect1 = await db.items.count!({ name: "tx_" }); | ||
if(expect1 !== 1) throw "db.tx failed"; | ||
|
||
} |