details: { operatorName: ‘$jsonSchema’, schemaRulesNotSatisfied: [Array] }
Estou tomando esse erro
const jsonProductSchema = {
$jsonSchema: {
bsonType: "object",
required: ["name", "valor", "status", "descricao", "caminho","[_idcategoria]"],
additionalProperties: false,
properties: {
_id: {},
name: {
bsonType: "string",
description: "'name' is required and is a string",
},
valor: {
bsonType: "string",
description: "'position' is required and is a number",
},
status: {
bsonType: "string",
description: "'level' is required and is one of 'indisponivel , disponivel ou nao fabricado mais'",
enum: ["indisponivel", "disponivel", "naofabricado"],
},
descricao: {
bsonType: "string",
description: "'descricao' is required and is a string",
},
caminho: {
bsonType: "string",
description: "'uma string com o caminho da imagem do produto'",
},
_idcategoria: {
bsonType: ["array"],
description: "'_id' is required and is an object id of 'Category' collection",
ref: "Category",
validationAction: "error",
type: "object",
}
},
},
};
import { Schema } from “inspector”;
import * as mongodb from “mongodb”;
export interface Product {
name: string;
valor: string ;
status: ‘indisponivel’ | ‘disponivel’ | ‘naofabricado’;
descricao: string;
caminho: string;
_id?: mongodb.ObjectId;
_idcategoria: Array<mongodb.ObjectId>;
}
nao sei consigo fazer o relacionamento