From f0ca97d30968d2be060d00aff72b67aaf8ab01cf Mon Sep 17 00:00:00 2001 From: Sungyun Hur Date: Wed, 15 Dec 2021 02:14:04 +0900 Subject: [PATCH] doc/indexes: add storage key section (#2218) --- doc/md/schema-indexes.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/md/schema-indexes.md b/doc/md/schema-indexes.md index 8a85ff65d..6f3475150 100755 --- a/doc/md/schema-indexes.md +++ b/doc/md/schema-indexes.md @@ -212,3 +212,16 @@ CREATE INDEX `users_description` ON `users`(`description`(128)) CREATE INDEX `users_c1_c2_c3` ON `users`(`c1`(100), `c2`(200), `c3`) ``` +## Storage Key + +Like Fields, custom index name can be configured using the `StorageKey` method. +It's mapped to a index name in SQL dialects. + +```go +func (User) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("field1", "field2"). + StorageKey("custom_index"), + } +} +```