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
Copy file name to clipboardExpand all lines: doc/index.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1289,7 +1289,7 @@ await Person
1289
1289
});
1290
1290
```
1291
1291
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`.
1293
1293
1294
1294
```js
1295
1295
await Person
@@ -1299,6 +1299,7 @@ await Person
1299
1299
lastName:'Lawrence',
1300
1300
1301
1301
movies: [{
1302
+
// This will relate to an existing movie with id 2636
1302
1303
"#dbRef":2636
1303
1304
}, {
1304
1305
// 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
1378
1379
```
1379
1380
1380
1381
> 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:
1382
1383
1383
1384
```js
1384
1385
// The return value of `upsertGraph` is the input graph converted into model instances.
@@ -1554,6 +1555,8 @@ await Person
1554
1555
}, options);
1555
1556
```
1556
1557
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
+
1557
1560
> You can disable updates, inserts, deletes etc. for the whole `upsertGraph` operation or for
1558
1561
> individual relations by using the `noUpdate`, `noInsert`, `noDelete` etc. options. See
1559
1562
> [`UpsertGraphOptions`](#upsertgraphoptions) docs for more info.
0 commit comments