const livroSchema = new mongoose.Schema(
{
id: {Type: String},
titulo: {type: String, required: true},
autor: {type: String, required: true},
editora: {type: String, required: true},
numeroPaginas: {type: Number},
}
);
Esta retornando o erro abaixo
/alura-node/node_modules/mongoose/lib/helpers/schema/idGetter.js:16
schema.virtual('id').get(idGetter);
^
TypeError: schema.virtual(...).get is not a function
at addIdGetter (/home/trol/alura-node/node_modules/mongoose/lib/helpers/schema/idGetter.js:16:24)
at Schema._preCompile (/home/trol/alura-node/node_modules/mongoose/lib/schema.js:2211:3)
at Function.compile (/home/trol/alura-node/node_modules/mongoose/lib/model.js:4853:10)
at Mongoose._model (/home/trol/alura-node/node_modules/mongoose/lib/index.js:565:27)
at Mongoose.model (/home/trol/alura-node/node_modules/mongoose/lib/index.js:523:27)
at file:///home/trol/alura-node/src/models/livro.js:13:25
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
at async loadESM (node:internal/process/esm_loader:91:5)
[nodemon] app crashed - waiting for file changes before starting...
Comentando o 'id: {Type: String}' funcionou pra mim, mas na video aula traz ele como string e funciona. Não compreendi este erro!