You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-24Lines changed: 26 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ pnpm add loro-mirror loro-crdt
31
31
32
32
## Quick Start
33
33
34
-
### Core Usage
34
+
### Usage
35
35
36
36
```typescript
37
37
import { LoroDoc } from"loro-crdt";
@@ -99,27 +99,27 @@ Loro Mirror provides a declarative schema system that enables:
99
99
-**Root Schema**: The root object defined via `schema({...})`, containing only Loro container types (Map/List/Text/MovableList).
100
100
-**Field Schema**: A combination of primitive types (string, number, boolean), ignore fields, and Loro containers.
101
101
-**Schema Options (`SchemaOptions`)**:
102
-
-**`required?: boolean`**: Whether the field is required (default: `true`).
103
-
-**`defaultValue?: unknown`**: Default value for the field.
104
-
-**`description?: string`**: Description of the field.
105
-
-**`validate?: (value) => boolean | string`**: Custom validation function. Return `true` for valid values, or a string as error message for invalid ones.
102
+
-**`required?: boolean`**: Whether the field is required (default: `true`).
103
+
-**`defaultValue?: unknown`**: Default value for the field.
104
+
-**`description?: string`**: Description of the field.
105
+
-**`validate?: (value) => boolean | string`**: Custom validation function. Return `true` for valid values, or a string as error message for invalid ones.
106
106
107
107
#### Schema Definition API
108
108
109
109
-**Primitive Types**:
110
-
-`schema.String<T extends string = string>(options?)` - String type with optional generic constraint
111
-
-`schema.Number(options?)` - Number type
112
-
-`schema.Boolean(options?)` - Boolean type
113
-
-`schema.Ignore(options?)` - Field that won't sync with Loro, useful for local computed fields
110
+
-`schema.String<T extends string = string>(options?)` - String type with optional generic constraint
111
+
-`schema.Number(options?)` - Number type
112
+
-`schema.Boolean(options?)` - Boolean type
113
+
-`schema.Ignore(options?)` - Field that won't sync with Loro, useful for local computed fields
114
114
115
115
-**Container Types**:
116
-
-`schema.LoroMap(definition, options?)` - Object container that can nest arbitrary field schemas
117
-
- Supports dynamic key-value definition with `catchall`: `schema.LoroMap({...}).catchall(valueSchema)`
118
-
-`schema.LoroMapRecord(valueSchema, options?)` - Equivalent to `LoroMap({}).catchall(valueSchema)` for homogeneous maps
119
-
-`schema.LoroList(itemSchema, idSelector?, options?)` - Ordered list container
0 commit comments