mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/doc: fix grammar and typos and doc
Summary: {F206501895}
Reviewed By: alexsn
Differential Revision: D17182079
fbshipit-source-id: 9311fc8b3f2608b9cd5ae5cd0a805b0cf73c4029
This commit is contained in:
committed by
Facebook Github Bot
parent
9ab0a28ffe
commit
95d878d3c6
@@ -20,7 +20,7 @@ In order to generate one or more schema templates, run `entc init` as follows:
|
||||
entc init User Pet
|
||||
```
|
||||
|
||||
`init` will created the 2 schemas (`user.go` and `pet.go`) under `ent/schema`.
|
||||
`init` will create the 2 schemas (`user.go` and `pet.go`) under the `ent/schema` directory.
|
||||
If the `ent` directory does not exist, it will create it as well. The convention
|
||||
is to have an `ent` directory under the root directory of the project.
|
||||
|
||||
@@ -33,7 +33,7 @@ the assets for working with your entities. Run the following command:
|
||||
entc generate ./ent/schema
|
||||
```
|
||||
|
||||
You should note, that `goimports` is required for the codegen, and it can be installed using:
|
||||
You should note that `goimports` is required for the codegen, and it can be installed using:
|
||||
|
||||
```bash
|
||||
go get -u golang.org/x/tools/cmd/goimports
|
||||
@@ -43,9 +43,9 @@ The `generate` command generates the following assets for the schemas:
|
||||
|
||||
- `Client` and `Tx` objects used for interacting with the graph.
|
||||
- CRUD builders for each schema type. See [CRUD](crud.md) for more info.
|
||||
- Entity object (Go struct) for each of the schema type.
|
||||
- Package contains constants and predicates used for interacting with the builders.
|
||||
- A `migrate` package, for SQL dialects. See [Migration](migrate.md) for more info.
|
||||
- Entity object (Go struct) for each of the schema types.
|
||||
- Package containing constants and predicates used for interacting with the builders.
|
||||
- A `migrate` package for SQL dialects. See [Migration](migrate.md) for more info.
|
||||
|
||||
## Code Generation Options
|
||||
|
||||
@@ -77,7 +77,7 @@ In order to get a description of your graph schema, run:
|
||||
entc describe ./ent/schema
|
||||
```
|
||||
|
||||
An example for the output, is as follows:
|
||||
An example for the output is as follows:
|
||||
|
||||
```console
|
||||
Pet:
|
||||
|
||||
@@ -9,8 +9,8 @@ will generate the following assets:
|
||||
- `Client` and `Tx` objects used for interacting with the graph.
|
||||
- CRUD builders for each schema type. See [CRUD](crud.md) for more info.
|
||||
- Entity object (Go struct) for each of the schema type.
|
||||
- Package contains constants and predicates used for interacting with the builders.
|
||||
- A `migrate` package, for SQL dialects. See [Migration](migrate.md) for more info.
|
||||
- Package containing constants and predicates used for interacting with the builders.
|
||||
- A `migrate` package for SQL dialects. See [Migration](migrate.md) for more info.
|
||||
|
||||
## Create A New Client
|
||||
|
||||
@@ -119,7 +119,7 @@ pedro := client.Pet. // PetClient.
|
||||
|
||||
## Update One
|
||||
|
||||
If an entity that already returned from the database.
|
||||
Update an entity that was returned from the database.
|
||||
|
||||
```go
|
||||
a8m, err = a8m.Update(). // User update builder.
|
||||
@@ -211,7 +211,7 @@ err := client.User.
|
||||
Exec(ctx)
|
||||
```
|
||||
|
||||
Delete by id.
|
||||
Delete by ID.
|
||||
|
||||
```go
|
||||
err := client.User.
|
||||
|
||||
@@ -74,12 +74,12 @@ if err != nil {
|
||||
## Universal IDs
|
||||
|
||||
By default, SQL primary-keys start from 1 for each table; which means that multiple entities of different types
|
||||
can share the same id. Unlike AWS Neptune, where vertex ids are UUIDs.
|
||||
can share the same ID. Unlike AWS Neptune, where vertex IDs are UUIDs.
|
||||
|
||||
This does not work well if you work with [GraphQL](https://graphql.org/learn/schema/#scalar-types) which requires
|
||||
the object identifier to be unique.
|
||||
This does not work well if you work with [GraphQL](https://graphql.org/learn/schema/#scalar-types), which requires
|
||||
the object ID to be unique.
|
||||
|
||||
To enable the universal-ids for your project, pass the `WithGlobalUniqueID` option to the migration.
|
||||
To enable the Universal-IDs support for your project, pass the `WithGlobalUniqueID` option to the migration.
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -108,8 +108,8 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
**How does it work?** `ent` migration allocates a 1<<32 range for the ids of each entity (table),
|
||||
**How does it work?** `ent` migration allocates a 1<<32 range for the IDs of each entity (table),
|
||||
and store this information in a table named `ent_types`. For example, type `A` will have the range
|
||||
of `[1,4294967296)` for its ids, and type `B` will have the range of `[4294967296,8589934592)`, etc.
|
||||
of `[1,4294967296)` for its IDs, and type `B` will have the range of `[4294967296,8589934592)`, etc.
|
||||
|
||||
Note that if this option is enabled, the maximum number of possible tables are **65535**.
|
||||
Note that if this option is enabled, the maximum number of possible tables is **65535**.
|
||||
@@ -32,7 +32,7 @@ func (User) Indexes() []ent.Index {
|
||||
}
|
||||
```
|
||||
|
||||
Note that, for setting a single field as unique, use the `Unique`
|
||||
Note that for setting a single field as unique, use the `Unique`
|
||||
method on the field builder as follows:
|
||||
|
||||
```go
|
||||
@@ -47,7 +47,7 @@ func (User) Fields() []ent.Field {
|
||||
## Index On Edges
|
||||
|
||||
Indexes can be configured on composition of fields and edges. The main use-case
|
||||
is setting uniqueness on fields under specific relation. Let's take an example:
|
||||
is setting uniqueness on fields under a specific relation. Let's take an example:
|
||||
|
||||

|
||||
|
||||
@@ -151,5 +151,5 @@ The full example exists in [GitHub](https://github.com/facebookincubator/ent/tre
|
||||
|
||||
## Dialect Support
|
||||
|
||||
Indexes are currently support only SQL dialects, and do not support Gremlin.
|
||||
Indexes currently support only SQL dialects, and do not support Gremlin.
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ The full example exists in [GitHub](https://github.com/facebookincubator/ent/tre
|
||||
|
||||
## Transactional Client
|
||||
|
||||
Sometimes, you have an existing code that already work with `*ent.Client`, and you want to change it (or wrap it)
|
||||
Sometimes, you have an existing code that already works with `*ent.Client`, and you want to change it (or wrap it)
|
||||
to interact with transactions. For these use cases, you have a transactional client. An `*ent.Client` that you can
|
||||
get from an existing transaction.
|
||||
|
||||
|
||||
@@ -153,13 +153,13 @@ func Gen(ctx context.Context, client *ent.Client) error {
|
||||
}
|
||||
```
|
||||
|
||||
Let's go over a few traversals, and show the code for then:
|
||||
Let's go over a few traversals, and show the code for them:
|
||||
|
||||

|
||||
|
||||
The traversal above starts from a `Group` entity, continue to its `admin` (edge),
|
||||
continue to its `friends` (edge), get their `pets` (edge), get each pet's `friends` (edge),
|
||||
and request their owners.
|
||||
The traversal above starts from a `Group` entity, continues to its `admin` (edge),
|
||||
continues to its `friends` (edge), gets their `pets` (edge), gets each pet's `friends` (edge),
|
||||
and requests their owners.
|
||||
|
||||
```go
|
||||
func Traverse(ctx context.Context, client *ent.Client) error {
|
||||
@@ -186,7 +186,7 @@ What about the following traversal?
|
||||
|
||||

|
||||
|
||||
We want to get all pets (entities), that have an `owner` (`edge`), that it's a `friend`
|
||||
We want to get all pets (entities) that have an `owner` (`edge`) that is a `friend`
|
||||
(edge) of some group `admin` (edge).
|
||||
|
||||
```go
|
||||
|
||||
Reference in New Issue
Block a user