Closed luluhoc closed 2 years ago
import * as mongoose from 'mongoose';
import { nanoid } from 'nanoid';
export interface IEmbed extends mongoose.Document {
_id: string;
title: string;
iFrameLink: string;
createdAt: Date;
updatedAt: Date;
}
const EmbedSchema = new mongoose.Schema<IEmbed>(
{
_id: {
type: String,
default: () => nanoid(),
},
title: String,
iFrameLink: String,
},
{
timestamps: true,
},
);
const Test = mongoose.model<IEmbed>('Embed', EmbedSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017')
await mongoose.connection.dropDatabase();
await Test.create({})
console.log('done');
}
run();
6.2.6
Do you want to request a feature or report a bug? bug What is the current behavior? After updating to the latest mongoose version 6.2.6 I get this error from typescript in my model
Expected 0 type arguments, but got 1.ts(2558)
it is on new mongoose.Schema<IEmbed>
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version. MongoDB 5 Mongoose 6.2.6 Node v17.1.0