Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
simonpaul08 opened this issue Aug 29, 2023 · 5 comments

Comments

@simonpaul08
Copy link

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
Copy link

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

@ramiel
Copy link
Owner

ramiel commented Dec 20, 2023

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

@simonpaul08
Copy link
Author

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

@ramiel
Copy link
Owner

ramiel commented Dec 21, 2023

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
Copy link

namhnz commented May 22, 2024

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<...>>'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants