-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a41c29
commit b784881
Showing
3 changed files
with
5 additions
and
790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ order: 3 | |
# Seeding data | ||
|
||
This guide will show you how to create a `User` list and add initial data to it | ||
using the `createItems` method. This process is also called `seeding`. | ||
using the `createItems` function. This process is also called `seeding`. | ||
|
||
> **Note:** In a previous chapter the code was split up over separate files, while this is preferred in a real code base, in this part everything is put in one file for clarity reasons. | ||
|
@@ -84,7 +84,6 @@ The [`createItems`](https://www.keystonejs.com/keystonejs/server-side-graphql-cl | |
- `listKey`: the Keystone list name | ||
- `items`: the array of objects to be created. | ||
|
||
|
||
```javascript | ||
createItems({ | ||
keystone, | ||
|
@@ -269,7 +268,7 @@ const keystone = new Keystone({ | |
name: 'John Duck', | ||
email: '[email protected]', | ||
password: 'dolphins', | ||
posts: { | ||
posts: { | ||
// Filtering list of items where title contains the word `React` | ||
connect: post.filter(p => /\bReact\b/i.test(p.title)).map(i => ({ id: i.id })), | ||
}, | ||
|
@@ -287,6 +286,7 @@ const keystone = new Keystone({ | |
}, | ||
}); | ||
``` | ||
Clear the database, start the Keystone application and visit the Admin UI. Take a look at the user `John Duck`, he has two posts associated with him (there were two posts with the word `React` in the `title`). | ||
Clear the database, start the Keystone application and visit the Admin UI. Take a look at the user `John Duck`, he has two posts associated with him (there were two posts with the word `React` in the `title`). | ||
If you want to explore other utility functions for `CRUD` operations, please refer to [server-side GraphQL client](https://www.keystonejs.com/keystonejs/server-side-graphql-client) API for more details. |
Oops, something went wrong.