Skip to content

Commit

Permalink
Add example of max number of items in an array
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhghomon committed Jan 2, 2025
1 parent a7609a5 commit 1b03801
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/content/doc-surrealql/statements/define/field.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ DEFINE FIELD user_id ON TABLE user TYPE uuid|int;

### Array type

You can also set a field to have the array data type. The array data type can be used to store a list of values. You can also set the data type of the array's contents.
You can also set a field to have the array data type. The array data type can be used to store a list of values. You can also set the data type of the array's contents, as well as the maximum number of items that it can hold.

```surql
-- Set a field to have the array data type
Expand All @@ -81,6 +81,9 @@ DEFINE FIELD posts ON TABLE user TYPE array;
-- Set a field to have the array object data type
DEFINE FIELD emails ON TABLE user TYPE array<object>;
-- Field for a block in a game showing the possible directions a character can move next
DEFINE FIELD next_paths ON TABLE block TYPE array<"north" | "east" | "south" | "west", 4>;
```

### Making a field optional
Expand Down

0 comments on commit 1b03801

Please sign in to comment.