mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
cmd/ent: rename init to new (#3311)
* cmd: rename init to new Signed-off-by: Giau. Tran Minh <hello@giautm.dev> * doc: update guide to use new command Signed-off-by: Giau. Tran Minh <hello@giautm.dev> --------- Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
This commit is contained in:
@@ -17,7 +17,7 @@ go get -d entgo.io/ent/cmd/ent
|
||||
In order to generate one or more schema templates, run `ent init` as follows:
|
||||
|
||||
```bash
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init User Pet
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new User Pet
|
||||
```
|
||||
|
||||
`init` will create the 2 schemas (`user.go` and `pet.go`) under the `ent/schema` directory.
|
||||
|
||||
@@ -32,7 +32,7 @@ go mod init entdemo
|
||||
Go to the root directory of your project, and run:
|
||||
|
||||
```console
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init User
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new User
|
||||
```
|
||||
|
||||
The command above will generate the schema for `User` under `entdemo/ent/schema/` directory:
|
||||
@@ -264,7 +264,7 @@ Let's create 2 additional entities named `Car` and `Group` with a few fields. We
|
||||
to generate the initial schemas:
|
||||
|
||||
```console
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init Car Group
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new Car Group
|
||||
```
|
||||
|
||||
And then we add the rest of the fields manually:
|
||||
|
||||
@@ -55,7 +55,7 @@ Entity schemas are usually stored inside `ent/schema` directory under
|
||||
the root directory of your project, and can be generated by `entc` as follows:
|
||||
|
||||
```console
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init User Group
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new User Group
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
@@ -11,7 +11,7 @@ For the purpose of the example, we'll generate the following graph:
|
||||
The first step is to generate the 3 schemas: `Pet`, `User`, `Group`.
|
||||
|
||||
```console
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init Pet User Group
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new Pet User Group
|
||||
```
|
||||
|
||||
Add the necessary fields and edges for the schemas:
|
||||
|
||||
@@ -15,7 +15,7 @@ go mod init ent-grpc-example
|
||||
Next, we use `go run` to invoke the ent code generator to initialize a schema:
|
||||
|
||||
```console
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init User
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new User
|
||||
```
|
||||
|
||||
Our directory should now look like:
|
||||
|
||||
@@ -29,7 +29,7 @@ go get -d entgo.io/ent/cmd/ent
|
||||
```
|
||||
|
||||
```console
|
||||
go run -mod=mod entgo.io/ent/cmd/ent init Todo
|
||||
go run -mod=mod entgo.io/ent/cmd/ent new Todo
|
||||
```
|
||||
|
||||
After installing Ent and running `ent init`, your project directory should look like this:
|
||||
@@ -49,7 +49,7 @@ entity schemas.
|
||||
|
||||
## Code Generation
|
||||
|
||||
When we ran `ent init Todo` above, a schema named `Todo` was created in the `todo.go` file under the`todo/ent/schema/` directory:
|
||||
When we ran `ent new Todo` above, a schema named `Todo` was created in the `todo.go` file under the`todo/ent/schema/` directory:
|
||||
|
||||
```go
|
||||
package schema
|
||||
|
||||
Reference in New Issue
Block a user