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: docs/guide/prologue/getting-started.md
+6-30Lines changed: 6 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -97,33 +97,11 @@ export default store
97
97
98
98
Now you are ready to go. Vuex ORM creates a namespaced module called `entities` and registers all models within by their `entity` name.
99
99
100
-
## Create a Repository
100
+
## Creating Data
101
101
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.
103
103
104
-
```js
105
-
constpostRepo=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
-
importPostfrom'@/models/Post'
114
-
115
-
exportdefault {
116
-
computed: {
117
-
postRepo () {
118
-
returnthis.$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.
127
105
128
106
```js
129
107
import { mapRepos } from'@vuex-orm/core'
@@ -138,9 +116,7 @@ export default {
138
116
139
117
You can learn more about repositories at [Repository: Getting Started](../repository/getting-started).
140
118
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:
0 commit comments