Skip to content

Commit

Permalink
docs for create-attributes, created the intro and the CreateStringAtt…
Browse files Browse the repository at this point in the history
…ribute
  • Loading branch information
madpelsm committed May 24, 2022
1 parent 5bac76c commit 6fe7003
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/examples/Database/create-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Usage of CreateAttribute methods

Attributes that are available:
- string
- Enum
- Email
- Ip
- Url
- Integer
- Float
- Boolean

Note: for the optional parameters, there is new type created (since GO doesn't have optional or default arguments). The Optional type is defined as a struct with fields:

- Value -> this contains the value
- Specified -> wether or not it is specified (defaults to false)

Optional[T]{} -> replace T with the desired type (string, int, ...)
empty optional = will see as "optional value not set"

Example Use of the CreateAttribute functions:

CreateStringAttribute("unique()", "StringName", 15, false, Optional[string]{Value: "MyDefaultString",Specified: false}, Optional[bool]{})
This wil create a String attribute with name "StringName" that is max. 15 characters long and has default value "MyDefaultString". Since the isArray is an empty Optional[bool], the isArray bool will be false -> this is not an array

0 comments on commit 6fe7003

Please sign in to comment.