ent/doc: add docs for storage-key option

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/36

Reviewed By: dlvhdr

Differential Revision: D17395353

fbshipit-source-id: b06de30a66ee4bb79f68a585a981a52ee3f341be
This commit is contained in:
Ariel Mashraki
2019-09-16 06:05:27 -07:00
committed by Facebook Github Bot
parent 624ecd2cc7
commit 1f0f39df38
5 changed files with 30 additions and 31 deletions

View File

@@ -1,2 +0,0 @@
*/node_modules
*.log

View File

@@ -1,10 +0,0 @@
FROM node:8.11.4
WORKDIR /app/website
EXPOSE 3000 35729
COPY ./docs /app/docs
COPY ./website /app/website
RUN yarn install
CMD ["yarn", "start"]

View File

@@ -1,18 +0,0 @@
version: "3"
services:
docusaurus:
build: .
ports:
- 3000:3000
- 35729:35729
volumes:
- ./docs:/app/docs
- ./website/blog:/app/website/blog
- ./website/core:/app/website/core
- ./website/i18n:/app/website/i18n
- ./website/pages:/app/website/pages
- ./website/static:/app/website/static
- ./website/sidebars.json:/app/website/sidebars.json
- ./website/siteConfig.js:/app/website/siteConfig.js
working_dir: /app/website

View File

@@ -67,8 +67,22 @@ Flags:
--idtype [int string] type of the id field (default int)
--storage strings list of storage drivers to support (default [sql])
--target string target directory for codegen
--template strings external templates to execute
```
## Storage Options
`entc` can generate assets for both SQL and Gremlin dialect. The default dialect is SQL.
## External Templates
`entc` accepts external Go templates to execute. If the template name is already defined by
`entc`, it will override the existing one. Otherwise, it will write the execution output to
a file with the same name as the template.
Example of a custom template provides a `Node` API for GraphQL -
[Github](https://github.com/facebookincubator/ent/blob/master/entc/integration/template/ent/template/node.tmpl).
## Schema Description
In order to get a description of your graph schema, run:

View File

@@ -251,6 +251,21 @@ func (User) Fields() []ent.Field {
}
```
## Storage Key
Custom storage name can be configured using the `StorageKey` method.
It's mapped to a column name in SQL dialects and to property name in Gremlin.
```go
// Fields of the user.
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("name").
StorageKey(`old_name"`),
}
}
```
## Indexes
Indexes can be defined on multi fields and some types of edges as well.
However, you should note, that this is currently an SQL-only feature.
@@ -335,4 +350,4 @@ type User struct {
Tenant string
Logger *log.Logger
}
```
```