N
Nuxt8mo ago
Niza

Nuxt-Mongoose

Hi, I am experiencing an issue with the nuxt-mongoose framework. I am attempting to locate a document in the MongoDB database collection that matches a specific key/field called kinde_id, but I keep receiving an error. Please refer to the attached images above to view the code. I can retrieve (find) documents that match the _id quite alright but kinde_id doesn't work. Could anyone help out with this issue? This is the error I am getting:
No overload matches this call.
Overload 1 of 4, '(filter?: FilterQuery<{ name: "string"; kinde_id: "string"; }> | undefined, projection?: ProjectionType<{ name: "string"; kinde_id: "string"; }> | null | undefined, options?: QueryOptions<...> | ... 1 more ... | undefined): Query<...>', gave the following error.
Type 'string | number | true | Record<string, any> | QueryValue[] | QueryValue[]' is not assignable to type 'Condition<"string"> | undefined'.
Type 'number' is not assignable to type 'Condition<"string"> | undefined'.
Overload 2 of 4, '(filter?: FilterQuery<{ name: "string"; kinde_id: "string"; }> | undefined, projection?: ProjectionType<{ name: "string"; kinde_id: "string"; }> | null | undefined): Query<...>', gave the following error.
Type 'string | number | true | Record<string, any> | QueryValue[] | QueryValue[]' is not assignable to type 'Condition<"string"> | undefined'.
Overload 3 of 4, '(filter?: FilterQuery<{ name: "string"; kinde_id: "string"; }> | undefined): Query<(Document<unknown, {}, { name: "string"; kinde_id: "string"; }> & { name: "string"; kinde_id: "string"; } & { ...; }) | null, Document<...> & ... 1 more ... & { ...; }, {}, { ...; }, "findOne">', gave the following error.
Type 'string | number | true | Record<string, any> | QueryValue[] | QueryValue[]' is not assignable to type 'Condition<"string"> | undefined'.ts(2769)
(property) kinde_id?: Condition<"string"> | undefined
No overload matches this call.
Overload 1 of 4, '(filter?: FilterQuery<{ name: "string"; kinde_id: "string"; }> | undefined, projection?: ProjectionType<{ name: "string"; kinde_id: "string"; }> | null | undefined, options?: QueryOptions<...> | ... 1 more ... | undefined): Query<...>', gave the following error.
Type 'string | number | true | Record<string, any> | QueryValue[] | QueryValue[]' is not assignable to type 'Condition<"string"> | undefined'.
Type 'number' is not assignable to type 'Condition<"string"> | undefined'.
Overload 2 of 4, '(filter?: FilterQuery<{ name: "string"; kinde_id: "string"; }> | undefined, projection?: ProjectionType<{ name: "string"; kinde_id: "string"; }> | null | undefined): Query<...>', gave the following error.
Type 'string | number | true | Record<string, any> | QueryValue[] | QueryValue[]' is not assignable to type 'Condition<"string"> | undefined'.
Overload 3 of 4, '(filter?: FilterQuery<{ name: "string"; kinde_id: "string"; }> | undefined): Query<(Document<unknown, {}, { name: "string"; kinde_id: "string"; }> & { name: "string"; kinde_id: "string"; } & { ...; }) | null, Document<...> & ... 1 more ... & { ...; }, {}, { ...; }, "findOne">', gave the following error.
Type 'string | number | true | Record<string, any> | QueryValue[] | QueryValue[]' is not assignable to type 'Condition<"string"> | undefined'.ts(2769)
(property) kinde_id?: Condition<"string"> | undefined
My ./server/api/users/index.get.ts file
The userModel for the database (auto imported by nuxt)
4 Replies
Niza
NizaOP8mo ago
bump
oneeach
oneeach8mo ago
Are you importing your userModal in your index.get.ts?
Niza
NizaOP8mo ago
Hi, yes it gets auto imported. I figured out the solution My Schema/Modal is incorrect
IceMeltAll
IceMeltAll3mo ago
how is your nuxt-mongoose connection to instance set up? Initially for me it was working using .env and configuring it in nuxt.config.ts like this mongoose: { uri: 'process.env.MONGODB_URI', options: {}, modelsDir: 'models', devtools: true, }, but once I started adding /server/methods and /server/middleware the console when running npm run dev keeps outputing
ERROR Error connecting to MongoDB: MongoParseError: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"
Want results from more Discord servers?
Add your server