Skip to content

Commit

Permalink
rename Photon to Prisma Client JS
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Jan 15, 2020
1 parent 2e27870 commit 94a8d11
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions docs/photon/migrating-from-sequelize.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ This will initialize a new Prisma project name "photonjs_app" and start the init
4. "Database options": **Use existing PostgreSQL schema**
5. "Non-empty schemas": **public**
6. "Prisma 2 tools": confirm the default selections
7. "Photon is available in these languages": **TypeScript**
7. "Prisma Client JS is available in these languages": **TypeScript**
8. **Just the Prisma schema**

The introspection process is now complete. You should see a message like:
Expand Down Expand Up @@ -296,7 +296,7 @@ import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()
```
Now you can start using the `prisma` instance and interact with your database programmatically with the generated Photon API.
Now you can start using the `prisma` instance and interact with your database programmatically with the generated Prisma Client JS API.

The `PrismaClient` instance connects [lazily](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#managing-connections) when the first request is made to the API (`connect()` is called for you under the hood).

Expand Down Expand Up @@ -463,7 +463,7 @@ app.get('/users', async (req, res) => {

```

Your generated Photon API will expose the following [CRUD operations](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#crud) for the `Task` and `User` models:
Your generated Prisma Client JS API will expose the following [CRUD operations](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#crud) for the `Task` and `User` models:
- `findOne`
- `findMany`
- `create`
Expand All @@ -473,7 +473,7 @@ Your generated Photon API will expose the following [CRUD operations](https://gi
- `delete`
- `deleteMany`

So to implement the same route and endpoint in your Prisma Client JS project, go to your `index.ts` file, and in the `/users` endpoint for the `app.get` route, fetch all the posts from the database with [`findMany`](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#findMany), a method exposed for the `User` model with the generated Photon API. Then send the results back. Note that the API calls are asynchronous so we can `await` the results of the operation.
So to implement the same route and endpoint in your Prisma Client JS project, go to your `index.ts` file, and in the `/users` endpoint for the `app.get` route, fetch all the posts from the database with [`findMany`](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#findMany), a method exposed for the `User` model with the generated Prisma Client JS API. Then send the results back. Note that the API calls are asynchronous so we can `await` the results of the operation.

```ts
import * as express from 'express'
Expand Down
8 changes: 4 additions & 4 deletions docs/photon/migrating-from-typeorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This will initialize a new Prisma project name "photonjs_app" and start the init
4. "Database options": **Use existing PostgreSQL schema**
5. "Non-empty schemas": **public**
6. "Prisma 2 tools": confirm the default selections
7. "Photon is available in these languages": **TypeScript**
7. "Prisma Client JS is available in these languages": **TypeScript**
8. **Just the Prisma schema**

The introspection process is now complete. You should see a message like:
Expand Down Expand Up @@ -247,7 +247,7 @@ import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()
```
Now you can start using the `prisma` instance and interact with your database programmatically with the generated Photon API.
Now you can start using the `prisma` instance and interact with your database programmatically with the generated Prisma Client JS API.

The `PrismaClient` instance connects [lazily](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#managing-connections) when the first request is made to the API (`connect()` is called for you under the hood).

Expand Down Expand Up @@ -367,7 +367,7 @@ createConnection().then(connection => {
```


Your generated Photon API will expose the following [CRUD operations](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#crud) for the `Category` and `Post` models:
Your generated Prisma Client JS API will expose the following [CRUD operations](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#crud) for the `Category` and `Post` models:
- `findOne`
- `findMany`
- `create`
Expand All @@ -379,7 +379,7 @@ Your generated Photon API will expose the following [CRUD operations](https://gi

### Migrating the `/posts` route (`GET`)

So to implement the same route and endpoint in your Prisma Client JS project, go to your `index.ts` file, and in the `/posts` endpoint for the `app.get` route, fetch all the posts from the database with [`findMany`](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#findMany), a method exposed for the `Post` model with the generated Photon API. Then send the results back. Note that the API calls are asynchronous so we can `await` the results of the operation.
So to implement the same route and endpoint in your Prisma Client JS project, go to your `index.ts` file, and in the `/posts` endpoint for the `app.get` route, fetch all the posts from the database with [`findMany`](https://github.com/prisma/prisma2/blob/master/docs/photon/api.md#findMany), a method exposed for the `Post` model with the generated Prisma Client JS API. Then send the results back. Note that the API calls are asynchronous so we can `await` the results of the operation.

```ts
import * as express from 'express'
Expand Down
16 changes: 8 additions & 8 deletions docs/photon/use-only-photon.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You can use Photon as an ORM in your application without using Lift for database migrations. This is useful for _existing applications_ when there already is a working migration system or when you don't have the rights inside your organization to perform database migrations yourself.

When using Photon without Lift, you obtain your data model definition by _introspecting_ your database schema and generating the Prisma data model from it. The generated data model then serves as foundation for Photon's generated CRUD API. Whenever a schema migration is performed on the database afterwards, you need to re-introspect your database (which updates your data model) and re-generate your Photon API.
When using Photon without Lift, you obtain your data model definition by _introspecting_ your database schema and generating the Prisma data model from it. The generated data model then serves as foundation for Photon's generated CRUD API. Whenever a schema migration is performed on the database afterwards, you need to re-introspect your database (which updates your data model) and re-generate your Prisma Client JS API.

**This page is about using Photon with an existing database**. Learn more about getting started from scratch with Photon and Lift [here](./).

Expand Down Expand Up @@ -37,7 +37,7 @@ Once you're done with the interactive prompt, the CLI sets out for 3 major tasks

1. Introspecting your database schema
1. Generating a data model based on the introspection
1. Generating the Photon API in your selected language
1. Generating the Prisma Client JS API in your selected language

Plus, if you've selected a boilerplate to get started, it downloads the boilerplate code and configures it to connect to your database and match the generated data model.

Expand All @@ -55,9 +55,9 @@ It is recommended to also install the `prisma2` CLI as a development dependency:
npm install prisma2 --save-dev
```

Now you can import it from `node_modules/@prisma/client` and start calling your database via the [generated Photon API](./api.md).
Now you can import it from `node_modules/@prisma/client` and start calling your database via the [generated Prisma Client JS API](./api.md).

### 3. Customize your Photon API
### 3. Customize your Prisma Client JS API

One benefit of having the data model as an intermediate representation of your database schema is that lets you to _decouple_ the database schema from your data access API. For example, you can map cryptic table names to friendlier model names to be used in your API.

Expand Down Expand Up @@ -87,7 +87,7 @@ model Customer @@map(name: "_customers") {
}
```

After running another `prisma2 generate`, your Photon API now looks as follows:
After running another `prisma2 generate`, your Prisma Client JS API now looks as follows:

```ts
await photon.customers.findMany({
Expand All @@ -97,10 +97,10 @@ await photon.customers.findMany({

### 5. Evolve your application

Whenever the database schema changes throughout the lifetime of your application, you need to re-generate your Photon API to ensure it still matches the underlying database structures. The workflow for that typically involves two steps:
Whenever the database schema changes throughout the lifetime of your application, you need to re-generate your Prisma Client JS API to ensure it still matches the underlying database structures. The workflow for that typically involves two steps:

1. Re-introspecting your database schema to update the data model
1. Re-generate your Photon API
1. Re-generate your Prisma Client JS API

In CLI commands, this looks as follows:

Expand Down Expand Up @@ -154,4 +154,4 @@ When using MongoDB, you need to provide your [MongoDB connection string](https:/

### Demo scripts

When you're selecting the **Demo script** option, the Prisma Framework CLI will provide a runnable Node.js/TypeScript script that showcases usage of the Photon API and gives you a foundation for further exploration.
When you're selecting the **Demo script** option, the Prisma Framework CLI will provide a runnable Node.js/TypeScript script that showcases usage of the Prisma Client JS API and gives you a foundation for further exploration.
4 changes: 2 additions & 2 deletions docs/relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ model User {
}
```

## Relations in the generated Photon API
## Relations in the generated Prisma Client JS API

The [generated Photon API](./photon/api.md) comes with many helpful features for relations (find examples below):
The [generated Prisma Client JS API](./photon/api.md) comes with many helpful features for relations (find examples below):

- Fluent API to traverse relations on the returned object
- Nested creates, updates and connects (also referred to as _nested writes_) with transactional guarantees
Expand Down
2 changes: 1 addition & 1 deletion docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Here's a list of information that is contained in an error report:
- Versions of Prisma tools
- Project metadata

_Project metadata_ includes your Prisma schema, used CLI commands or usage of certain features in the Photon API. Note that the connection details of any of your data sources will be obscured in the error report.
_Project metadata_ includes your Prisma schema, used CLI commands or usage of certain features in the Prisma Client JS API. Note that the connection details of any of your data sources will be obscured in the error report.

Here's a list of information that is **never** contained in an error report:

Expand Down
6 changes: 3 additions & 3 deletions docs/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ While there's a lot of of ambiguity and nuance to each of these properties (e.g.

Photon provides a data access API to read and write data from a database. For relational databases, Photon's API abstracts over SQL where transactions are a common feature. While Photon doesn't allow for the same flexibility a SQL-level transaction provides, it covers the vast majority of use cases developers have for transactions with [**nested writes**](./relations.md#nested-writes).

A nested write lets you perform a single Photon API call with multiple _operations_ that touch multiple [_related_](./relations.md#nested-writes) records, for example creating a _user_ together with a _post_ or updating an _order_ together with an _invoice_. When a nested write is performed, Photon ensures that it will either succeed or fail as a whole.
A nested write lets you perform a single Prisma Client JS API call with multiple _operations_ that touch multiple [_related_](./relations.md#nested-writes) records, for example creating a _user_ together with a _post_ or updating an _order_ together with an _invoice_. When a nested write is performed, Photon ensures that it will either succeed or fail as a whole.

Here are examples for nested writes in the Photon API:
Here are examples for nested writes in the Prisma Client JS API:

```ts
// Create a new user with two posts in a
Expand Down Expand Up @@ -51,7 +51,7 @@ const updatedPost: Post = await photon.posts.update({
})
```

## Future transaction support in the Photon API
## Future transaction support in the Prisma Client JS API

Transactions are a commonly used feature in relational as well as non-relational databases and Photon might support more transaction mechanisms in the future. Specifically, the following two use cases will be supported:

Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ The Prisma schema contains three important elements of your project:
The [data model definition](./data-modeling.md#data-model-definition) inside the schema file has the following responsibilities:

- It's a _declarative_ description of your underlying database schema
- It provides the foundation for the generated [Photon API](./photon/api.md)
- It provides the foundation for the generated [Prisma Client JS API](./photon/api.md)

Its main building blocks are [models](./data-modeling.md#models) which map to _tables_ in the underlying PostgreSQL database. The [fields](./data-modeling.md#fields) of a model map to _columns_ of a table.

Expand Down Expand Up @@ -469,9 +469,9 @@ model Post {
Be sure to **save the file**. As you save it, you can observe your terminal window to see Prisma's activity:

- It added a `Category` table to your database schema. It also added a _relation table_ called `_CategoryToPost` to the database schema to represent the many-to-many relation. Note that the shape of the relation table will be configurable in the future, learn more in the [spec](https://github.com/prisma/specs/tree/master/schema#explicit-many-to-many-mn-relationships).
- It regenerated the Photon API to add CRUD operations for the new `Category` model.
- It regenerated the Prisma Client JS API to add CRUD operations for the new `Category` model.

Since the Photon API has been updated, you can now update the code in `script.ts` to create new categories and connect them to existing (or new) posts. As an example, this code snippet would create a new category called "prisma" and connect it to two existing posts:
Since the Prisma Client JS API has been updated, you can now update the code in `script.ts` to create new categories and connect them to existing (or new) posts. As an example, this code snippet would create a new category called "prisma" and connect it to two existing posts:

```ts
const category = await photon.categories.create({
Expand Down Expand Up @@ -500,7 +500,7 @@ Terminate the development mode by hitting <kbd>CTRL</kbd>+<kbd>C</kbd> two times

## 5. Migrate the database with Lift

You've introduced changes to your data model that are already reflected in the database and in your Photon API thanks to `prisma2 dev`. To persists your migration in Lift's migration history, you need to run through the process of migrating your database with Lift.
You've introduced changes to your data model that are already reflected in the database and in your Prisma Client JS API thanks to `prisma2 dev`. To persists your migration in Lift's migration history, you need to run through the process of migrating your database with Lift.

Every schema migration with Lift follows a 3-step-process:

Expand Down

0 comments on commit 94a8d11

Please sign in to comment.