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 32966b5 commit aca7890
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 155 deletions.
2 changes: 1 addition & 1 deletion docs/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ This directory contains documentation about the Prisma Framework core components
- [SQLite](./connectors/sqlite.md)
- [MongoDB](./connectors/mongo.md)
- Generators
- [Photon.js](./generators/photonjs.md)
- [Prisma Client JS](./generators/photonjs.md)
44 changes: 22 additions & 22 deletions docs/core/generators/photonjs.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Photon.js generator
# Prisma Client JS generator

The Photon.js generator can be used in a [Prisma schema file](../../prisma-schema-file.md) to generate the Photon database client for Node.js and TypeScript. The API of the generated client is documented [here](../../photon/api.md).
The Prisma Client JS generator can be used in a [Prisma schema file](../../prisma-schema-file.md) to generate Prisma's database client for Node.js and TypeScript. The API of Prisma Client JS is documented [here](../../photon/api.md).

## Node.js requirements

The generated data access code of the `photonjs` generator targets [ES2016](https://exploringjs.com/es2016-es2017/) which means you need [Node.js 8.x](https://nodejs.org/en/download/releases/) or newer to be able to use it.
The generated data access code of the `prisma-client-js` generator targets [ES2016](https://exploringjs.com/es2016-es2017/) which means you need [Node.js 10.x](https://nodejs.org/en/download/releases/) or newer to be able to use it.

## Specifying the right platform for Photon.js
## Specifying the right platform for Prisma Client JS

Photon.js depends on a _query engine_ that's running as a _binary_ on the same host as your application. When deploying your Photon-based application to production, you need to ensure that the binary used by Photon can run in your production environment, i.e. it needs to be compatible with the runtime of your deployment provider.
Prisma Client JS depends on a _query engine_ that's running as a _binary_ on the same host as your application. When deploying your Prisma-based application to production, you need to ensure that the binary used by Prisma Client JS can run in your production environment, i.e. it needs to be compatible with the runtime of your deployment provider.

The query engine binary is downloaded when you run `prisma2 generate`, it is then stored alongside the generated Photon code inside `node_modules/@prisma` (or the [custom `output` path](../../photon/codegen-and-node-setup.md) you specified). This section explains how you can determine which binary should be downloaded when `prisma2 generate` is executed to ensure compatibility at runtime.
The query engine binary is downloaded when you run `prisma2 generate`, it is then stored alongside the generated Prisma Client JS code inside `node_modules/@prisma` (or the [custom `output` path](../../photon/codegen-and-node-setup.md) you specified). This section explains how you can determine which binary should be downloaded when `prisma2 generate` is executed to ensure compatibility at runtime.

You can read more about this topic in the [specification](https://github.com/prisma/specs/blob/master/binaries/Readme.md).

Expand All @@ -20,33 +20,33 @@ A **platform** is a _managed environment_. This includes deployment providers su

### Generator options

To determine the platform Photon is running on, you can provide two options to the `photonjs` generator:
To determine the platform Prisma Client JS is running on, you can provide two options to the `prisma-client-js` generator:

| Name | Required | Description | Purpose |
| ---------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `binaryTargets` | No | An array of binary names that are required by the application. Either a _file path_ to a binary, a package name from the [available binaries](#available-binaries) or the special value `"native"`. **Default**: `["native"]`. | Declarative way to download the required binaries. |

If `binaryTargets` contains a _file path_ to a binary, you need to provide the path to the binary via an environment variable:

- If you're using a custom binary for the **query engine** (Photon.js), set the file path to it as the `PRISMA_QUERY_ENGINE_BINARY` environment variable.
- If you're using a custom binary for the **query engine** (Prisma Client JS), set the file path to it as the `PRISMA_QUERY_ENGINE_BINARY` environment variable.
- If you're using a custom binary for the **migration engine** (Lift), set the file path to it as the `PRISMA_MIGRATION_ENGINE_BINARY` environment variable.

### Default: The `native` platform

When no [generator options](#generator-options) are passed to the `photonjs` generator in your [Prisma schema file](../prisma-schema-file.md), the Prisma CLI will download the binary for the operating system on which `prisma2 generate` was executed. The following two configurations are therefore equivalent, because `["native"]` is the default value for `binaryTargets`:
When no [generator options](#generator-options) are passed to the `prisma-client-js` generator in your [Prisma schema file](../prisma-schema-file.md), the Prisma CLI will download the binary for the operating system on which `prisma2 generate` was executed. The following two configurations are therefore equivalent, because `["native"]` is the default value for `binaryTargets`:

```prisma
generator photon {
provider = "photonjs"
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
```

has the **same behavior** as:

```prisma
generator photon {
provider = "photonjs"
generator client {
provider = "prisma-client-js"
}
```

Expand All @@ -58,11 +58,11 @@ We provide various pre-built binaries. You can find them in the [specs binary ta

### Example

This example shows the configuration of a Photon.js generator for local development (`native` can resolve to any other platform) and AWS Lambda (Node 10) as the production environment.
This example shows the configuration of a Prisma Client JS generator for local development (`native` can resolve to any other platform) and AWS Lambda (Node 10) as the production environment.

```prisma
generator photon {
provider = "photonjs"
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.0.x"]
}
```
Expand All @@ -73,11 +73,11 @@ You can find the instructions for manually compiling the query engine binary [he

## Example

To invoke the generator, you need to add a [`generator`](../../prisma-schema-file.md#generators-optional) block to your schema file and specify the `photonjs` provider:
To invoke the generator, you need to add a [`generator`](../../prisma-schema-file.md#generators-optional) block to your schema file and specify the `prisma-client-js` provider:

```prisma
generator js {
provider = "photonjs"
generator client {
provider = "prisma-client-js"
}
// ... the file should also contain connectors and a data model definition
Expand All @@ -89,11 +89,11 @@ Once added, you can invoke the generator using the following command:
prisma2 generate
```

It will then store the generated Photon API in the default location `node_modules/@prisma/photon` directory. Learn more about the [generated Photon API](../../photon/api.md).
It will then store the generated Prisma Client JS API in the default location `node_modules/@prisma/client` directory. Learn more about the [generated Prisma Client JS API](../../photon/api.md).

## Mapping types from the data model

The Photon.js generator provides the following mapping from data model [scalar types](../../data-modeling.md#scalar-types) to JavaScript/TypeScript types:
The Prisma Client JS generator provides the following mapping from data model [scalar types](../../data-modeling.md#scalar-types) to JavaScript/TypeScript types:

| Type | JS / TS |
| ---------- | --------- |
Expand All @@ -105,7 +105,7 @@ The Photon.js generator provides the following mapping from data model [scalar t

## Reserved model names

When generating Photon.js based on your [data model definition](./data-modeling.md#data-model-definition), there are a number of reserved names that you can't use for your models. Here is a list of the reserved names:
When generating Prisma Client JS based on your [data model definition](./data-modeling.md#data-model-definition), there are a number of reserved names that you can't use for your models. Here is a list of the reserved names:

- `String`
- `Int`
Expand Down
22 changes: 11 additions & 11 deletions docs/data-modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ Technically, a model can be named anything that adheres to this regular expressi
[A-Za-z_][A-Za-z0-9_]*
```

### Model operations in the Photon API (CRUD)
### Model operations in the Prisma Client JS API (CRUD)

Every _model_ in the data model definition will result in a number of CRUD operations in the generated [Photon API](./photon/api.md):
Every _model_ in the data model definition will result in a number of CRUD operations in the generated [Prisma Client JS API](./photon/api.md):

- `findMany`
- `findOne`
Expand All @@ -118,24 +118,24 @@ Every _model_ in the data model definition will result in a number of CRUD opera
- `updateMany`
- `deleteMany`

The operations are accessible via a generated property on the Photon instance. By default the name of the property is the plural, lowercase form of the model name, e.g. `users` for a `User` model or `posts` for a `Post` model.
The operations are accessible via a generated property on the Prisma Client JS instance. By default the name of the property is the plural, lowercase form of the model name, e.g. `users` for a `User` model or `posts` for a `Post` model.

Here is an example illustrating the use of a `users` property from the [Photon.js API](./photon/api.md):
Here is an example illustrating the use of a `users` property from the [Prisma Client JS API](./photon/api.md):

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

Note that for Photon.js the name of the `users` property is auto-generated using the [`pluralize`](https://github.com/blakeembrey/pluralize) package.
Note that for Prisma Client JS the name of the `users` property is auto-generated using the [`pluralize`](https://github.com/blakeembrey/pluralize) package.

## IDs

Every model in your Prisma schema needs to have a unique ID. In relational databases, this unique ID corresponds to a column with a primary key constraint. Note that [composite primary keys are not yet supported](https://github.com/prisma/photonjs/issues/339) (but will be soon).
Every model in your Prisma schema needs to have a unique ID. In relational databases, this unique ID corresponds to a column with a primary key constraint. Note that [composite primary keys are not yet supported](https://github.com/prisma/prisma-client-js/issues/339) (but will be soon).

To determine which field of a model is the ID field, you can annotate it with the `@id` attribute. Fields annotated with the `@id` attribute must be of type `String` or `Int`:

Expand All @@ -155,10 +155,10 @@ model User {
}
```

Note that in the above cases, you must provide your own ID values when creating new records for the `User` model using Photon.js, e.g.:
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 photon.users.create({
const newUser = await prisma.users.create({
data: {
id: 1,
name: 'Alice',
Expand Down Expand Up @@ -520,7 +520,7 @@ Learn more about relations [here](./relations.md).

## Reserved model names

When generating Photon.js based on your [data model definition](./data-modeling.md#data-model-definition), there are a number of reserved names that you can't use for your models. Here is a list of the reserved names:
When generating Prisma Client JS based on your [data model definition](./data-modeling.md#data-model-definition), there are a number of reserved names that you can't use for your models. Here is a list of the reserved names:

- `String`
- `Int`
Expand Down
6 changes: 3 additions & 3 deletions docs/development-mode.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Development mode

The Prisma Framework supports a _development mode_ which can be launched using the `prisma2 dev` command. When in development mode, the Prisma Frameowrk runs a development server in the background that watches your [Prisma schema file](./prisma-schema-file.md).
The Prisma Framework supports a _development mode_ which can be launched using the `prisma2 dev` command. When in development mode, the Prisma Framework runs a development server in the background that watches your [Prisma schema file](./prisma-schema-file.md).

Whenever you save any changes in the schema file, the development server:

- (re)generates your data source clients (e.g. Photon)
- (re)generates your data source clients (e.g. Prisma Client JS)
- updates your database schema ([read below](#migrations-in-development-mode))
- creates a [Prisma Studio](https://github.com/prisma/studio) endpoint for you

Depending on whether you're using [only Photon](./photon/use-only-photon.md) or [only Lift](./lift/use-only-lift.md), it might only perform one of the above tasks.
Depending on whether you're using [only Prisma Client JS](./photon/use-only-photon.md) or [only Lift](./lift/use-only-lift.md), it might only perform one of the above tasks.

## Starting development mode

Expand Down

0 comments on commit aca7890

Please sign in to comment.