Skip to content

Commit

Permalink
Fix JS examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy committed Sep 23, 2024
1 parent a51f411 commit 2da7e0b
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/content/doc-surrealdb/security/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ Examples using the JavaScript SDK or a raw HTTP request.
```javascript
const db = new Surreal();
db.connect('ws://localhost:8000/rpc', {
ns: 'test',
db: 'test',
namespace: 'test',
database: 'test',
});

db.signin({
user: 'john',
pass: 'VerySecurePassword!',
username: 'john',
password: 'VerySecurePassword!',
});
```

Expand Down Expand Up @@ -83,17 +83,17 @@ Notice how we need to pass along `NS` and `DB` properties here, to let SurrealDB
```javascript
const db = new Surreal();
db.connect('ws://localhost:8000/rpc', {
ns: 'test',
db: 'test',
namespace: 'test',
database: 'test',
});

db.signin({
// Because we are signin in a database user, we need to let SurrealDB know on which database this user is located.
NS: 'test',
DB: 'test',
namespace: 'test',
database: 'test',

user: 'mary',
pass: 'VerySecurePassword!',
username: 'mary',
password: 'VerySecurePassword!',
});
```

Expand Down Expand Up @@ -185,21 +185,23 @@ Examples using the JavaScript SDK or a raw HTTP request.
```js
const db = new Surreal();
db.connect('ws://localhost:8000/rpc', {
ns: 'test',
db: 'test',
namespace: 'test',
database: 'test',
});

db.signup({
NS: 'test',
DB: 'test',
namespace: 'test',
database: 'test',

// Provide the name of the access method
AC: 'user',
access: 'user',

// Provide the variables used by the signup query
name: 'John Doe',
email: '[email protected]',
password: 'VerySecurePassword!',
variables: {
name: 'John Doe',
email: '[email protected]',
password: 'VerySecurePassword!',
}
});
```
#### HTTP Request
Expand All @@ -222,20 +224,22 @@ Examples using the JavaScript SDK or a raw HTTP request.
```js
const db = new Surreal();
db.connect('ws://localhost:8000/rpc', {
ns: 'test',
db: 'test',
namespace: 'test',
database: 'test',
});

db.signin({
NS: 'test',
DB: 'test',
namespace: 'test',
database: 'test',

// Provide the name of the access method
AC: 'user',
access: 'user',

// Provide the variables used by the signin query
email: '[email protected]',
password: 'VerySecurePassword!',
variables: {
email: '[email protected]',
password: 'VerySecurePassword!',
}
});
```

Expand Down

0 comments on commit 2da7e0b

Please sign in to comment.