Missing Schema Error: Schema hasn't been registered for model "[object Object]". Use mongoose model(name, schema) at Mongoose model error occurred
need solution for this problem
in ./src/models/channel.js
file:
const { Schema, model } = require("mongoose");
// Discord' channel model
const channelSchema = new Schema({
identifier: { type: String, required: true },
message: { type: String, default: "ping !" },
guild: { type: String, required: true },
type: { type: String, required: true },
mode: { type: Boolean }
});
module.exports = model("Channel", channelSchema);
in other files:
const Channel = require("../models/channel");
const toto = await Channel.create({
identifier: 1,
guild: "toto",
type: "tata",
});
console.log(toto);