Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic doc structure & add basic types #429

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file added docs/1.API&Examples/index.md
Empty file.
1 change: 1 addition & 0 deletions docs/2..Tutorials/1.about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# About Metaschema
1 change: 1 addition & 0 deletions docs/2..Tutorials/2.concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Concepts
120 changes: 120 additions & 0 deletions docs/2..Tutorials/3.guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Guides

## Use datatypes for write shema

### Basic types

- string
- number
- boolean
- bigint
- symbol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symbol is not supported for schemas


```javascript
// shema
({
/* STRING */
field1: { type: 'string' }, // or short {field1: "string"}
URVL marked this conversation as resolved.
Show resolved Hide resolved

// use string length limit (static length - 5 chars)
field2: { type: 'string', length: 5 },
// use string length limit (minimum length - 10 chars)
field3: { type: 'string', length: { min: 10 } },
// setup string min and max length limit (min- 5, max - 12)
field4: { type: 'string', length: [5, 12] },

/* NUMBER */
field5: { type: 'number' }, // or short {field2: "number"}

/* BOOLEAN */
field6: { type: 'boolean' }, // or short {field3: "boolean"}

/* BIGINT */
field7: { type: 'bigint' }, // or short {field7: "bigint"}

/* SYMBOL */
field8: { type: 'symbol' }, // or short {field8: "symbol"}
URVL marked this conversation as resolved.
Show resolved Hide resolved
});
```

```javascript
// valid data for shema
const data = {
field1: 'tihs is another string', // use 'string' type
field2: 'abcde', // use string length limit (static length - 5 chars)
field3: '123456789aebene', // use 'string' type end min(10) length limit
field4: '12345678ee', // use 'string' type end min(5) + max(12) length limit
field5: 1234, // use 'number' type
field6: true, // use 'boolean' type
field7: 123456789n, // use 'bigint' type
field8: Symbol('symbolForFiled'), // use 'symbol' type
URVL marked this conversation as resolved.
Show resolved Hide resolved
};
```

---

### Advanced (structured) types

#### 馃憠馃徏 Object collection

#### 馃憠馃徏 Collections

```javascript
/* BASE */

// shema
({
field1: { array: 'number' },
});

// valid data for shema
const data = {
field1: [1, 2, 3],
};
```

```javascript
/* LENGTH LIMIT */

// shema
({
field1: { type: 'array', value: 'number', length: 10 }
// or short alternative
field2: { array: 'number', length: 10 }
})

// valid data for shema
const data = {
field1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
field2: [11, 12, 13, 14, 15, 16, 17, 18, 19,20]
}

```

#### 馃憠馃徏 Set

#### 馃憠馃徏 Map

#### 馃憠馃徏 Tuples

---

### Nested types

---

### Type variations

### Optional types

### Helpers

- required (true | false)
- default

```javascript
({
field1: { type: 'string', required: false }, // use 'required' case
field2: { type: 'number', default: 150 }, // use 'default' case
});
```
Empty file added docs/2..Tutorials/index.md
Empty file.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Metashema