🪡Usage & Options

You can think of the Model Structure as a File or Folder for our Database. Our Model Structure Allows Us to Create a Collection in Our SQL Table. In the Example Below, You Can Examine the Block Showin

The Schema Structure is defined as seen in the Examples Below, and you can use it either as an Object Structure or directly by specifying the Type. There is a Section Below that Shows the Options for Using the Schema Structure as an Object.

Schema Options

Options
Type
Description

type

String, Number, Array, Object, Date, Boolean Or Cherry3 Types

This Setting Section will be the Type of the Key Specified in the Schema on the Database.

default

Any Type Value

If a value is not specified in the database registration process, this section will automatically add the entered value by default.

required

Boolean

This value will make it mandatory to enter data for the specified key structure. If no data is entered, it will not be recorded.

Model Options

Options
Type
Description

$timestamps

Boolean

If our feature is active in our Database Template, createdAt and updatedAt data will be automatically recorded in each row, and this information will be forwarded to you in each query. The returned data is of Date type.

$debug

Boolean

If our Debug Feature is Active, the output of all operations performed with the database and how they are performed will appear on our Console.

Example Usage

// Let's Transfer the Values in Our Package
const { Model, Schema, Types } = require('cherry3');

// Sample Schema Definition
const schema = Schema({
name: String,
age: Types.Number,
country: { type: String, default: '', required: false }
});

// Sample Model Definition
const model = new Model('users',schema,{ $timestamps: true, $debug: false });

// Our Database is Ready for Use 😁

Last updated