Trying to insert but getting a type error?

querying etc works fine.
No description
5 Replies
Angelelz
Angelelz10mo ago
You need to import the users table from the schema
panty slayer 007
panty slayer 00710mo ago
i tried that and it didn't work
No overload matches this call.
Overload 1 of 2, '(value: { id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 6 more ...; createdAt?: SQL<...> | ... 1 more ... | Placeholder<...>; }): MySqlInsertBase<...>', gave the following error.
Argument of type '{ username: string; password: string; }' is not assignable to parameter of type '{ id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 6 more ...; createdAt?: SQL<...> | ... 1 more ... | Placeholder<...>; }'.
Property 'id' is missing in type '{ username: string; password: string; }' but required in type '{ id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 6 more ...; createdAt?: SQL<...> | ... 1 more ... | Placeholder<...>; }'.
No overload matches this call.
Overload 1 of 2, '(value: { id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 6 more ...; createdAt?: SQL<...> | ... 1 more ... | Placeholder<...>; }): MySqlInsertBase<...>', gave the following error.
Argument of type '{ username: string; password: string; }' is not assignable to parameter of type '{ id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 6 more ...; createdAt?: SQL<...> | ... 1 more ... | Placeholder<...>; }'.
Property 'id' is missing in type '{ username: string; password: string; }' but required in type '{ id: string | SQL<unknown> | Placeholder<string, any>; username: string | SQL<unknown> | Placeholder<string, any>; password: string | SQL<unknown> | Placeholder<...>; ... 6 more ...; createdAt?: SQL<...> | ... 1 more ... | Placeholder<...>; }'.
this is happening
Angelelz
Angelelz10mo ago
The error is pretty clear You are missing an id in your values
panty slayer 007
panty slayer 00710mo ago
how can i handle errors? like if something is unique and people try to register with that username again and stuff.
Angelelz
Angelelz10mo ago
There are plenty of tutorials out there that explain this type of stuff
Want results from more Discord servers?
Add your server