Skip to content

Commit 7d66022

Browse files
committed
docs: adjust getting started guide
1 parent 6394862 commit 7d66022

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

docs/guide/prologue/getting-started.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,11 @@ export default store
9797

9898
Now you are ready to go. Vuex ORM creates a namespaced module called `entities` and registers all models within by their `entity` name.
9999

100-
## Create a Repository
100+
## Creating Data
101101

102-
Vuex ORM adopts the [Data Mapper](https://en.wikipedia.org/wiki/Data_mapper_pattern) pattern and uses _repositories_ to interact with the store. A repository is created using the `store.$repo()` method and passing in a model as the argument.
102+
Vuex ORM adopts the [Data Mapper](https://en.wikipedia.org/wiki/Data_mapper_pattern) pattern and uses _repositories_ to interact with the store. In order to create new data, you must first obtain a repository instance corresponding to the model.
103103

104-
```js
105-
const postRepo = store.$repo(Post)
106-
107-
postRepo.insert(posts)
108-
```
109-
110-
When creating repositories in a Vue component, you can also use `this.$store`:
111-
112-
```js
113-
import Post from '@/models/Post'
114-
115-
export default {
116-
computed: {
117-
postRepo () {
118-
return this.$store.$repo(Post)
119-
}
120-
}
121-
}
122-
```
123-
124-
### Map Repositories
125-
126-
However, it might be a bit cumbersome to create repositories like this, especially when you have multiple repositories that you want to use. In such cases, you can use the `mapRepos` helper:
104+
You may do so by using the `mapRepos` helper function.
127105

128106
```js
129107
import { mapRepos } from '@vuex-orm/core'
@@ -138,9 +116,7 @@ export default {
138116

139117
You can learn more about repositories at [Repository: Getting Started](../repository/getting-started).
140118

141-
## Inserting Data
142-
143-
Vuex ORM provides an `insert` method to insert new records to a collection. In the following example, we're passing in an array with a single post:
119+
Now, you may use `save` on the repository to create new records. In the following example, we're passing in an array with a single post:
144120

145121
```js
146122
import { mapRepos } from '@vuex-orm/core'
@@ -166,8 +142,8 @@ export default {
166142
}
167143
]
168144

169-
// Insert posts.
170-
this.postRepo.insert(posts)
145+
// Save posts.
146+
this.postRepo.save(posts)
171147
}
172148
}
173149
```

0 commit comments

Comments
 (0)