{
$jsonSchema: {
bsonType: "object",
required: ["nome", "integrantes"],
properties: {
nome: {
bsonType: "string",
description: "'nome' deve ser uma string que representa o nome da equipe e precisa ser informado."
},
integrantes: {
bsonType: ["string"],
description: "'integrantes' deve ser um array de string que representa o(s) nome(s) do(s) integrante(s) da equipe e precisa ser informado.",
minItems: 1,
uniqueItems: true
},
timestamps: {
createdAt: "criadaEm",
updatedAt: "atualizadaEm"
}
}
}
}
And the error is:
Parsing of collection validator failed :: caused by :: Unknown $jsonSchema keyword: createdAt
I am not too familiar with schema-validation but by looking at the first example of the documentation, I think that timestamps, being an object with 2 fields would need to be specified as
Unless of course, I misunderstand your intent and what your really want is to have have createdAt and updatedAt as top level attributes like nome and integrantes. If this is the case, then it should be:
I want to “enable” the timestamps of any document, renaming createdAt to criadaEm and updatedAt to atualizadaEm. I don’t know if it’s possible to do that in the schema validatior.
MongoDB has no default and automatic createdAt and updatedAt fields. Thanks you MongoDB since I do not want to pay performance penalty to a feature that I do not need in some of my use case.