Closed JaiSh12345 closed 2 years ago
Hi @JaiSh12345 to signin as a 'root' user don't specify a NS
or DB
in the signin()
method...
import Surreal from 'surrealdb.js';
const db = new Surreal('http://localhost:8000/rpc');
async function main() {
try {
// Signin as a root user
await db.signin({
user: 'root',
pass: 'root',
});
console.log('y');
// Select a specific namespace / database
await db.use('practice', 'buybig');
console.log(await db.select('users'));
} catch (e) {
console.error('ERROR', e);
}
}
main();
Okay! I don't know why I added NS
and DB
. I suppose I was playing around with it. Thanks!
Hmmm, but it's not ending the program correctly. I get:
C:\Users ... > node app.js
y
[ { email: 'john@gmail.com', id: 'users:john', pass: 'pass' } ]
^C
And it just hangs after the console log.
You have to close the client! The DB connection is still alive!
Ahh, okay, got it.
Just added a db.close();
at the end of the program.
I have recently come across SurrealDB, and installed it.
After adding to path, I started the server using
surreal start --log trace --user root --pass root
In my NodeJS app, I have the following code (adapted from your docs):
I am getting this error:
And this in my SurrealDB logs:
Accessing database through
VSCode
'sThunder Client
and SurrealDB cli tool works flawlessly.Any help is appreciated.
Environment: