Schema
You can create schemas using with @esosdb/utils
Setup
const { Schema } = require("@esosdb/utils")
//...
Syntax
new Schema(schemaName,schemaProps,timestamps)
Schema Name; Schema name is a string and required.
Schema Props; Schema props is an object and required.
Timestamps; Timestamps is boolean and not required.
Example
//...
const userSchema = {
name:{ type: "string", required: true },
surname: { type: "string", required: true },
age: { type: "number", required: false }
}
const User = new Schema("user",userSchema,true)
export { User }
In TS you need to write it as undefined including the "required:false" parts, to help us solve this: https://github.com/esosdb/utils/issues.
Last updated
Was this helpful?