Skip to content

Commit 1adc68f

Browse files
kibertoadkoskimas
authored andcommitted
Clarify #dbRef documentation
1 parent bf73d71 commit 1adc68f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

‎doc/index.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ await Person
12891289
});
12901290
```
12911291

1292-
> If you need to mix inserts and relates inside a single relation, you can use the special property `#dbRef`
1292+
> If you need to mix inserts and relates inside a single relation, you can use the special property `#dbRef` that explicitly points to an id of an entity which already exists in the database. Model `idColumn` of a related entity is used for the `#dbRef`.
12931293
12941294
```js
12951295
await Person
@@ -1299,6 +1299,7 @@ await Person
12991299
lastName: 'Lawrence',
13001300

13011301
movies: [{
1302+
// This will relate to an existing movie with id 2636
13021303
"#dbRef": 2636
13031304
}, {
13041305
// This will be inserted with an id.
@@ -1378,7 +1379,7 @@ You can read more about graph inserts from [this blog post](https://www.vincit.f
13781379
```
13791380

13801381
> By default `upsertGraph` method updates the objects that have an id, inserts objects that don't have an id and deletes
1381-
> all objects that are not present. Off course the delete only applies to relations and not the root. Here's a basic example:
1382+
> all objects that are not present. Of course the delete only applies to relations and not the root. Here's a basic example:
13821383
13831384
```js
13841385
// The return value of `upsertGraph` is the input graph converted into model instances.
@@ -1554,6 +1555,8 @@ await Person
15541555
}, options);
15551556
```
15561557

1558+
> You can use `upsertGraph` with `#dbRef` (same way as when using `insertGraph`). Alternatively, you can use `relate` option and pass an id as depicted above.
1559+
15571560
> You can disable updates, inserts, deletes etc. for the whole `upsertGraph` operation or for
15581561
> individual relations by using the `noUpdate`, `noInsert`, `noDelete` etc. options. See
15591562
> [`UpsertGraphOptions`](#upsertgraphoptions) docs for more info.

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"test-fast": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail --exclude \"tests/unit/relations/files/**\"",
1111
"test-opt": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail --trace_opt --trace_deopt --exclude \"tests/unit/relations/files/**\"",
1212
"test-prof": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --prof --exclude \"tests/unit/relations/files/**\"",
13+
"test-sqlite": "cross-env DATABASES=sqlite3 mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --exclude \"tests/unit/relations/files/**\"",
1314
"test-typings": "tsc",
1415
"coveralls": "cat ./testCoverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
1516
"perf": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf",
@@ -72,6 +73,7 @@
7273
"chai": "^4.2.0",
7374
"chai-subset": "^1.6.0",
7475
"coveralls": "^3.0.2",
76+
"cross-env": "^5.2.0",
7577
"eslint": "^5.9.0",
7678
"eslint-plugin-prettier": "^3.0.0",
7779
"expect.js": "^0.3.1",

0 commit comments

Comments
 (0)