Closed OTheNonE closed 5 months ago
When trying to update a user by the .update() function, you have to specify all fields of the record in order to update the record, otherwise the function throws an error.
.update()
I want to update the role of the following user:
{ id: "user:7k0keh247arqv02pjfdw" username: "guest" password: "someVerySecurePassword" role: "guest" }
I do this by using .update() as stated in the Docs:
let id = "user:7k0keh247arqv02pjfdw" let user = { role: "admin" } await db.update(id, user);
When doing this, i recieve the following error:
Error: There was a problem with the database: Found NONE for field `username`, with record `user:7k0keh247arqv02pjfdw`, but expected a string
I expect the function not to throw, but rather update only the fields specified in the user object.
user
surreal 1.1.1 for Windows
0.11.0
olavnon@gmail.com
db.update expects all the fields to be available and overwrites the whole record. What you are looking for is db.merge
db.update
db.merge
Oh my, how did miss this? Yes, i am looking for db.merge, thank you.
Describe the bug
When trying to update a user by the
.update()
function, you have to specify all fields of the record in order to update the record, otherwise the function throws an error.Steps to reproduce
I want to update the role of the following user:
I do this by using
.update()
as stated in the Docs:When doing this, i recieve the following error:
Expected behaviour
I expect the function not to throw, but rather update only the fields specified in the
user
object.SurrealDB version
surreal 1.1.1 for Windows
SurrealDB.js version
0.11.0
Contact Details
olavnon@gmail.com
Is there an existing issue for this?
Code of Conduct