mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
doc: add documentation for the sql/schemaconfig feature (#1215)
* Add documentation for the sql/schemaconfig feature * touch ups
This commit is contained in:
@@ -71,4 +71,19 @@ The `schema/snapshot` option tells `entc` (ent codegen) to store a snapshot of t
|
||||
and use it to automatically solve merge conflicts when user's schema can't be built.
|
||||
|
||||
This option can be added to projects using the `--feature schema/snapshot` flag, but please see
|
||||
[facebook/ent/issues/852](https://github.com/facebook/ent/issues/852) to get more context about it.
|
||||
[facebook/ent/issues/852](https://github.com/facebook/ent/issues/852) to get more context about it.
|
||||
|
||||
#### Schema Config
|
||||
|
||||
The `sql/schemaconfig` option lets you pass alternate SQL database names to models. This is useful when your models don't all live under one database and are spread out across different schemas.
|
||||
|
||||
This option can be added to projects using the `--feature sql/schemaconfig` flag. Once you generate the code, you can now use a new option as such:
|
||||
|
||||
```golang
|
||||
c, err := ent.Open(dialect, conn, ent.AlternateSchema(ent.SchemaConfig{
|
||||
User: "usersdb",
|
||||
Car: "carsdb",
|
||||
}))
|
||||
c.User.Query().All(ctx) // SELECT * FROM `usersdb`.`users`
|
||||
c.Car.Query().All(ctx) // SELECT * FROM `carsdb`.`cars`
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user