ramiel / mongoose-sequence

Sequence and autoincrement handling for mongoose
GNU General Public License v2.0
277 stars 57 forks source link

Trying to implement mongoose sequence in type "module" es6 but it does not work #137

Open simonpaul08 opened 10 months ago

simonpaul08 commented 10 months ago

This is the code for the Schema =>

import mongoose, { Schema } from "mongoose"; import Inc from 'mongoose-sequence';

const AutoIncrement = Inc(mongoose);

const noteSchema = new Schema( { user: { type: mongoose.Schema.Types.ObjectId, required: true, ref: 'User' }, title: { type: String, required: true }, text: { type: String, required: true }, completed: { type: Boolean, default: false } }, { timestamps: true } )

noteSchema.plugin(AutoIncrement, { inc_field: "ticket", id: "ticketNums", start_seq: 500 });

export default mongoose.model('Note', noteSchema);

do let me know what am I doing wrong..

loulou1994 commented 6 months ago

Facing same issue here and I just wanted to know if you figured something out?

ramiel commented 6 months ago

You're facing the same issue, but what's the issue exactly?

simonpaul08 commented 6 months ago

still getting the same error, no solution yet. It could be because of the type "module" but I am not sure

ramiel commented 6 months ago

Can you please report the exact error? In your initial report there is only the code, not the error. Otherwsie, can you make a reproduction?

namhnz commented 1 month ago

It has error: Argument of type 'typeof import("mongoose")' is not assignable to parameter of type 'Schema<any, Model<any, any, any, any, any, any>, {}, {}, {}, {}, DefaultSchemaOptions, { [x: string]: unknown; }, Document<unknown, {}, FlatRecord<{ [x: string]: unknown; }>> & FlatRecord<...> & Required<...>>'.