Skip to content

Commit

Permalink
adjust for breaking change of preview021
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Jan 30, 2020
1 parent 629644a commit ce3f596
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions docs/data-modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ The operations are accessible via a generated property on the Prisma Client JS i
Here is an example illustrating the use of a `users` property from the [Prisma Client JS API](./prisma-client-js/api.md):

```js
const newUser = await prisma.users.create({
const newUser = await prisma.user.create({
data: {
name: 'Alice',
},
})
const allUsers = await prisma.users.findMany()
const allUsers = await prisma.user.findMany()
```

Note that for Prisma Client JS the name of the `users` property is auto-generated using the [`pluralize`](https://github.com/blakeembrey/pluralize) package.
Expand Down Expand Up @@ -157,7 +157,7 @@ model User {
Note that in the above cases, you must provide your own ID values when creating new records for the `User` model using Prisma Client JS, e.g.:

```ts
const newUser = await prisma.users.create({
const newUser = await prisma.user.create({
data: {
id: 1,
name: 'Alice',
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const prisma = new PrismaClient()

async function main() {

const users = await prisma.users.findMany({
const users = await prisma.user.findMany({
include: {
postses: true,
}
Expand Down
40 changes: 20 additions & 20 deletions docs/prisma-client-js/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const prisma = new PrismaClient()

async function main() {
await prisma.connect()
const result = await prisma.users.findOne({
const result = await prisma.user.findOne({
where: { id: 1 },
})
// result = { id: 1, name: "Alice", role: "USER" }
Expand All @@ -91,7 +91,7 @@ In addition to CRUD operations, Prisma Client JS also allows for [_aggregation_
To return the number of elements in a list, you can the `count()` method on any model property on your `PrismaClient` instance, for example:

```ts
const userCount = await prisma.users.count()
const userCount = await prisma.user.count()
// userCount = 42
```

Expand Down Expand Up @@ -133,7 +133,7 @@ Note that you can not combine `select` and `include` in the following ways:
In this example, we're using `select` to exclusively select the `name` field of the returned `User` object:

```ts
const result = await prisma.users.findOne({
const result = await prisma.user.findOne({
where: { id: 1 },
select: { name: true },
})
Expand All @@ -145,7 +145,7 @@ const result = await prisma.users.findOne({
Sometimes you want to directly include a relation when retrieving data from a database. To eagerly load and include the relations of a model in an API call right away, you can use `include`:

```ts
const result = await prisma.users.findOne({
const result = await prisma.user.findOne({
where: { id: 1 },
include: { posts: true },
})
Expand Down Expand Up @@ -181,7 +181,7 @@ model User {
You can provide the `id` as input value in [`create`](#create) and [`update`](#update) operations, for example:

```ts
const user = await prisma.users.create({
const user = await prisma.user.create({
data: {
id: 1
}
Expand All @@ -208,15 +208,15 @@ model User {
When creating or updating a `User` record, you can create a new list or replace the current one with a new list like so:

```ts
await prisma.users.create({
await prisma.user.create({
data: {
coinFlips: {
set: [true, false]
}
}
})

await prisma.users.update({
await prisma.user.update({
where: { id: 42 ,}
data: {
coinFlips: {
Expand Down Expand Up @@ -261,7 +261,7 @@ Returns a single object identified by a _unique_ value (e.g. `id` or `email`). Y
#### Examples

```ts
const user = await prisma.users.findOne({
const user = await prisma.user.findOne({
where: { id: 1 },
})
```
Expand All @@ -288,7 +288,7 @@ For more filtering examples, look [here](#filtering).
#### Examples

```ts
const user = await prisma.users.findMany({
const user = await prisma.user.findMany({
where: { name: 'Alice' },
})
```
Expand All @@ -307,7 +307,7 @@ Creates a new record and returns the corresponding object. You can use the `sele
#### Examples

```ts
const user = await prisma.users.create({
const user = await prisma.user.create({
data: { name: 'Alice' },
})
```
Expand All @@ -327,7 +327,7 @@ Updates an existing record and returns the corresponding object. You can use the
#### Examples

```ts
const user = await prisma.users.update({
const user = await prisma.user.update({
where: { id: 1 },
data: { name: 'ALICE' },
})
Expand All @@ -347,7 +347,7 @@ Updates a batch of existing records in bulk and returns the number of updated re
#### Examples

```ts
const updatedUserCount = await prisma.users.updateMany({
const updatedUserCount = await prisma.user.updateMany({
where: { name: 'Alice' },
data: { name: 'ALICE' },
})
Expand All @@ -369,7 +369,7 @@ Updates an existing or creates a new record and returns the corresponding object
#### Examples

```ts
const user = await prisma.users.upsert({
const user = await prisma.user.upsert({
where: { id: 1 },
update: { name: "ALICE" },
create: { name: "ALICE" }
Expand All @@ -390,7 +390,7 @@ Deletes an existing record and returns the corresponding object. You can use the
#### Examples

```ts
const user = await prisma.users.delete({
const user = await prisma.user.delete({
where: { id: 1 },
})
```
Expand All @@ -408,7 +408,7 @@ Deletes a batch of existing records in bulk and returns the number of deleted re
#### Examples

```ts
const deletedUserCount = await prisma.users.deleteMany({
const deletedUserCount = await prisma.user.deleteMany({
where: { name: 'Alice' },
})
```
Expand All @@ -424,7 +424,7 @@ The `count()` method doesn't take any input arguments.
#### Examples

```ts
const userCount = await prisma.users.count()
const userCount = await prisma.user.count()
// userCount = 42
```

Expand Down Expand Up @@ -467,7 +467,7 @@ export declare type UserWhereInput = {
For example, to get the record for the user with the `id` 1, `where` is used in combination with the `id` `IntFilter`:
```ts
const result = await prisma.users.findMany({
const result = await prisma.user.findMany({
where: { id: 1 },
})
// result = [{
Expand All @@ -484,7 +484,7 @@ const result = await prisma.users.findMany({
To get the record for the user with the `name` Alice with a USER `role`, `where` is used in combination with the `name` `StringFilter` and the `role` `RoleFilter`:

```ts
const result = await prisma.users.findMany({
const result = await prisma.user.findMany({
where: {
name: 'Alice',
role: 'USER',
Expand All @@ -502,7 +502,7 @@ const result = await prisma.users.findMany({
To apply one of the operator filters (`AND`, `OR`, `NOT`), filter for the record where the user with the `name` Alice has a non-active status. Here, `where` is used in combination with the `name` `StringFilter`, the `active` `BooleanFilter`, and the `NOT` operator:

```ts
const result = await prisma.users.findMany({
const result = await prisma.user.findMany({
where: {
name: 'Alice',
NOT: {
Expand Down Expand Up @@ -555,7 +555,7 @@ You can reuse subparts of a Prisma Client JS query by not immediately evaluating

```ts
// Note the missing `await` here.
const currentUserQuery = prisma.users.findOne({ where: { id: prismarId } })
const currentUserQuery = prisma.user.findOne({ where: { id: prismarId } })

// Now you have the sub-part of a query that you can reuse.
const postsOfUser = await currentUserQuery.posts()
Expand Down
8 changes: 4 additions & 4 deletions docs/prisma-client-js/migrating-from-sequelize.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ app.use(bodyParser.json())
const prisma = new PrismaClient()

app.get('/users', async (req, res) => {
const users = await prisma.users.findMany()
const users = await prisma.user.findMany()
res.json(users)
})

Expand Down Expand Up @@ -519,7 +519,7 @@ So to implement the same route and endpoint in your Prisma Client JS project, go
//...
app.get(`/users/:id`, async (req, res) => {
const { id } = req.params
const user = await prisma.users.findOne({
const user = await prisma.user.findOne({
where: {
id: Number(id),
},
Expand Down Expand Up @@ -551,7 +551,7 @@ To implement the same route and endpoint in your Prisma Client JS project, go to
//...
app.post(`/tasks`, async (req, res) => {
const { title } = req.body
const post = await prisma.tasks.create({
const post = await prisma.task.create({
data: {
title,
},
Expand Down Expand Up @@ -583,7 +583,7 @@ To implement the same route and endpoint in your Prisma Client JS project, go to
//...
app.delete(`/tasks/:id`, async (req, res) => {
const { id } = req.params
const task = await prisma.tasks.delete({
const task = await prisma.task.delete({
where: {
id: Number(id),
},
Expand Down
8 changes: 4 additions & 4 deletions docs/prisma-client-js/migrating-from-typeorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ app.use(bodyParser.json())
const prisma = new PrismaClient()

app.get('/posts', async (req, res) => {
const posts = await prisma.posts.findMany()
const posts = await prisma.post.findMany()
res.send(posts)
})

Expand Down Expand Up @@ -437,7 +437,7 @@ So to implement the same route and endpoint in your Prisma Client JS project, go
//...
app.get(`/posts/:id`, async (req, res) => {
const { id } = req.params
const post = await prisma.posts.findOne({
const post = await prisma.post.findOne({
where: {
id: Number(id),
},
Expand Down Expand Up @@ -466,7 +466,7 @@ To implement the same route and endpoint in your Prisma Client JS project, go to
//...
app.post(`/posts`, async (req, res) => {
const { text, title } = req.body
const post = await prisma.posts.create({
const post = await prisma.post.create({
data: {
text,
title,
Expand Down Expand Up @@ -495,7 +495,7 @@ To implement the same route and endpoint in your Prisma Client JS project, go to
//...
app.delete(`/posts/:id`, async (req, res) => {
const { id } = req.params
const post = await prisma.posts.delete({
const post = await prisma.post.delete({
where: {
id: Number(id),
},
Expand Down
22 changes: 11 additions & 11 deletions docs/relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,15 @@ The fluent API lets you _fluently_ traverse the relations of your models via fun
This request returns all posts by a specific user:

```ts
const postsByUser: Post[] = await prisma.users
const postsByUser: Post[] = await prisma.user
.findOne({ where: { email: 'ada@prisma.io' } })
.posts()
```

This request returns all categories by a specific post:

```ts
const categoriesOfPost: Category[] = await prisma.posts
const categoriesOfPost: Category[] = await prisma.post
.findOne({ where: { id: 1 } })
.categories()
```
Expand All @@ -360,7 +360,7 @@ While the Fluent API allows you to write chainable queries, sometimes you may wa
You can also rewrite the query like this:

```ts
const postsByUser: Post[] = await prisma.posts.findMany({
const postsByUser: Post[] = await prisma.post.findMany({
where: {
author: { id: author.id },
},
Expand Down Expand Up @@ -406,7 +406,7 @@ Here are some examples of nested writes:
```ts
// Create a new user with two posts in a
// single transaction
const newUser: User = await prisma.users.create({
const newUser: User = await prisma.user.create({
data: {
email: 'alice@prisma.io',
posts: {
Expand All @@ -421,7 +421,7 @@ const newUser: User = await prisma.users.create({

```ts
// Change the author of a post in a single transaction
const updatedPost: Post = await prisma.posts.update({
const updatedPost: Post = await prisma.post.update({
where: { id: 5424 },
data: {
author: {
Expand All @@ -433,7 +433,7 @@ const updatedPost: Post = await prisma.posts.update({

```ts
// Remove the author from an existing post in a single transaction
const post: Post = await prisma.posts.update({
const post: Post = await prisma.post.update({
data: {
author: { disconnect: true },
},
Expand Down Expand Up @@ -476,7 +476,7 @@ Because there are circular relations between `User`, `Post` and `Comment`, you c
```ts
// Create a new post, connect to an existing user and create new,
// comments, users and posts in deeply nested operations
const post = await prisma.posts.create({
const post = await prisma.post.create({
data: {
author: {
connect: {
Expand Down Expand Up @@ -527,7 +527,7 @@ You can eagerly load relations on a model via `select` and `include` (learn more
```ts
// The returned post objects will only have the `id` and
// `author` property which carries the respective user object
const allPosts = await prisma.posts.findMany({
const allPosts = await prisma.post.findMany({
select: {
id: true,
author: true,
Expand All @@ -538,7 +538,7 @@ const allPosts = await prisma.posts.findMany({
```ts
// The returned posts objects will have all scalar fields of the `Post` model
// and additionally all the categories for each post
const allPosts = await prisma.posts.findMany({
const allPosts = await prisma.post.findMany({
include: {
categories: true,
},
Expand All @@ -548,7 +548,7 @@ const allPosts = await prisma.posts.findMany({
```ts
// The returned objects will have all scalar fields of the `User` model
// and additionally all the posts with their authors with their posts
await prisma.users.findMany({
await prisma.user.findMany({
include: {
posts: {
include: {
Expand All @@ -570,7 +570,7 @@ A relation filter is a filter operation that's applied to a related object of a
```ts
// Retrieve all posts of a particular user
// that start with "Hello"
const posts: Post[] = await prisma.users
const posts: Post[] = await prisma.user
.findOne({
where: { email: 'ada@prisma.io' },
})
Expand Down

0 comments on commit ce3f596

Please sign in to comment.