From 01a11f5ef1267de8ad96658382f6a93a0aa863a8 Mon Sep 17 00:00:00 2001 From: Quinten Cabo Date: Sat, 9 Sep 2023 18:15:03 +0200 Subject: [PATCH] fixed insert incorrect example --- .../2.model/7.single-table-inheritance.md | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/docs/content/1.guide/2.model/7.single-table-inheritance.md b/docs/content/1.guide/2.model/7.single-table-inheritance.md index c5c25ba02..54147f6e9 100644 --- a/docs/content/1.guide/2.model/7.single-table-inheritance.md +++ b/docs/content/1.guide/2.model/7.single-table-inheritance.md @@ -52,9 +52,7 @@ For typescript look at this [discussion](https://github.com/CodeDredd/pinia-orm/ Once you defined a sub-class, you can `insert` / `create` / `update` / `get` / `delete` entities using the Model static methods. For instance, to create or insert data: ```js -useRepo(Adult).insert({ - data: { id: 1, name: 'John Doe', job: 'Software Engineer' } -}) +useRepo(Adult).insert({id: 1, name: 'John Doe', job: 'Software Engineer' }) ``` And to fetch data: @@ -132,12 +130,11 @@ Now, you can create mixed types of records at once. ```js // Creating mixed data. -useRepo(Person).insert({ - data: [ +useRepo(Person).insert([ { type:'PERSON', id: 1, name: 'John Doe' }, { type:'ADULT', id: 2, name: 'Jane Doe', job: 'Software Engineer' } ] -}) +) const people = useRepo(Person).all() @@ -193,12 +190,11 @@ class Adult extends Person { And now you may use a custom `type` field when inserting data. ```js -useRepo(Person).insert({ - data: [ +useRepo(Person).insert([ { person_type: 'PERSON', id: 1, name: 'John Doe' }, { person_type: 'ADULT', id: 2, name: 'Jane Doe', job: 'Software Engineer' } ] -}) +) const people = useRepo(Person).all() @@ -253,12 +249,10 @@ Then you can fetch the key with its results. ```js // Creating mixed data -useRepo(Person).insert({ - data: [ +useRepo(Person).insert([ { type:'PERSON', id: 1, name: 'John Doe' }, { type:'ADULT', id: 2, name: 'Jane Doe', job: 'Software Engineer' } - ] -}) + ]) const people = useRepo(Person).all() @@ -321,21 +315,15 @@ class Address extends Model { And let's see what would happen in this case. ```js -useRepo(Address).insert({ - data: [ +useRepo(Address).insert([ { id: 1, city: 'TOKYO' }, { id: 2, city: 'PARIS' }, { id: 3, city: 'BERLIN' } - ] -}) + ]) -useRepo(Person).insert({ - data: { id: 1, home_address_id: 1, name: 'John Doe' } -}) +useRepo(Person).insert({ id: 1, home_address_id: 1, name: 'John Doe' }) -useRepo(Adult).insert({ - data: { id: 2, home_address_id: 2, work_address_id: 3, name: 'Jane Doe', job: 'Software Engineer' } -}) +useRepo(Adult).insert({ id: 2, home_address_id: 2, work_address_id: 3, name: 'Jane Doe', job: 'Software Engineer' }) const people = useRepo(Person).query().with(['home_address', 'work_address']).get()