Trying to insert but getting a type error?

querying etc works fine.
No description
5 Replies
Angelelz
Angelelz12mo ago
You need to import the users table from the schema
panty slayer 007
panty slayer 007OP12mo 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
Angelelz12mo ago
The error is pretty clear You are missing an id in your values
panty slayer 007
panty slayer 007OP12mo ago
how can i handle errors? like if something is unique and people try to register with that username again and stuff.
Angelelz
Angelelz12mo ago
There are plenty of tutorials out there that explain this type of stuff
Want results from more Discord servers?
Add your server