Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Sep 10, 2018
1 parent d7161d8 commit 361f722
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,16 @@ The Prisma API is deployed based on the datamodel and exposes CRUD & realtime op

The Prisma client connects to the Prisma API and lets you perform read and write operations in your database. This section explains how to use the Prisma client from **JavaScript**.

##### 4.1. Create Node app

Create a new Node script inside the `hello-world` directory:

```
touch index.js
```

Now add. the following code to it:
Now add the following code to it:

```js
const { prisma } = require('./prisma')
const { prisma } = require('./generated/prisma')

// A `main` function so that we can use async/await
async function main() {
Expand All @@ -131,13 +129,20 @@ async function main() {
const allUsers = await prisma.users()
console.log(allUsers)

// Read all posts from the database and print them to the console
const allPosts = await prisma.posts()
console.log(allPosts)
}

main().catch(e => console.error(e))
```

Finally, run the code using the following command:

```
node index.js
```

<details><summary><b>See more API operations</b></summary>
<p>

Expand All @@ -161,14 +166,12 @@ const usersCalledAlice = await prisma
```js
const deletedUser = await prisma
.deleteUser({ id: '__USER_ID__' })

```

</p>
</details>



#### 5. Next steps

Learn how to [build an app](https://www.prisma.io/docs/1.16/get-started/03-build-graphql-servers-with-prisma-e001/) using your Prisma client or [read more about how Prisma works](https://www.prisma.io/docs/1.16/understand-prisma/prisma-introduction-what-why-how-j9ff/).
Expand Down

0 comments on commit 361f722

Please sign in to comment.