Model() Method

The model() method creates and returns a model instance for defining and interacting with data models.

const modelName = 'MyModel';
const schemaDefinition = { /* Schema definition goes here */ };
const myModel = jsonverse.model(modelName, schemaDefinition);

or

const { Jsonverse } = require("jsonverse");
const db = new Jsonverse();

const { Schema } = Jsonverse;

const userSchema = new Schema({
  name: {
    type: String,
    required: true,
  },
  age: {
    type: Number,
    required: true,
  },
  email: {
    type: String,
    required: true,
    unique: true,
  },
});

module.exports = db.model("User", userSchema);

Use this method to create and configure data models within the jsonverse instance.