Skip to content

Commit

Permalink
todo for sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekwuno committed Oct 9, 2024
1 parent f2fc989 commit f6ef504
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 115 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
sidebar_position: 2
sidebar_label: Authentication
title: JavaScript | SDK | Authentication
sidebar_label: Authenticating users
title: JavaScript | SDK | Authenticating users
description: SurrealDB supports a number of methods for authenticating users and securing the database.
---

import Label from "@components/shared/Label.astro";
import Since from "@components/shared/Since.astro";

# Authentication
# Authenticating users

Since SurrealDB is a database that is designed to be used in a distributed environment, it is important to secure the database and the data that is stored in it. SurrealDB provides a number of methods for authenticating users and securing the database.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
---
sidebar_position: 1
sidebar_label: Initialization
title: JavaScript | SDK | Initialization
sidebar_label: Create a new connection
title: JavaScript | SDK | Create a new connection
description: The SurrealDB SDK for JavaScript enables simple and advanced querying of a remote or embedded database.
---

import Tabs from "@components/Tabs/Tabs.astro";
import TabItem from "@components/Tabs/TabItem.astro";
import Label from "@components/shared/Label.astro";

# Initialization
# Create a new connection

- Create a new project breakdown
- Step by step
- folder structure
- Using the SDK
- create a new instance of SurrealDB
- connect to a database endpoint
- switch to a specific namespace and database
- authenticate with an existing token
- authenticate using a pair of credentials
- use advanced custom logic to prepare the connection to the database



After [installing the SDK](/docs/sdk/javascript/setup) and selecting your import choice. You can initialize a new instance of SurrealDB and connect it to a database endpoint, which can be local or remote.

Expand Down
103 changes: 2 additions & 101 deletions src/content/doc-sdk-javascript/core/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,105 +5,6 @@ title: JavaScript | SDK | Methods
description: The SurrealDB SDK for JavaScript enables simple and advanced querying of a remote or embedded database.
---

# SDK methods
# Language Starter

The JavaScript SDK comes with a number of built-in functions.

<table>
<thead>
<tr>
<th scope="col">Function</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/initialization#connect"> <code> async db.connect(url, options) </code></a></td>
<td scope="row" data-label="Description">Connects to a local or remote database endpoint</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/initialization#wait"> <code> async db.wait() </code></a></td>
<td scope="row" data-label="Description">Waits for the connection to the database to succeed</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/initialization#close"> <code> async db.close() </code></a></td>
<td scope="row" data-label="Description">Closes the persistent connection to the database</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/initialization#use"> <code>async db.use(namespace,database)</code></a></td>
<td scope="row" data-label="Description">Switch to a specific namespace and database</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/initialization#info"> <code>async db.info&lt;T&gt;()</code></a></td>
<td scope="row" data-label="Description">Returns the record of an authenticated scope user</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/authentication#signup"> <code>async db.signup(vars)</code></a></td>
<td scope="row" data-label="Description">Signs this connection up to a specific authentication scope</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/authentication#signin"> <code>async db.signin(vars)</code></a></td>
<td scope="row" data-label="Description">Signs this connection in to a specific authentication scope</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/authentication#invalidate"> <code>async db.invalidate()</code></a></td>
<td scope="row" data-label="Description">Invalidates the authentication for the current connection</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/authentication#authenticate"> <code>async db.authenticate(token)</code></a></td>
<td scope="row" data-label="Description">Authenticates the current connection with a JWT token</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/parameters#let"> <code>async db.let(key,val)</code></a></td>
<td scope="row" data-label="Description">Assigns a value as a parameter for this connection</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/parameters#unset"> <code>async db.unset(key)</code></a></td>
<td scope="row" data-label="Description">Removes a parameter for this connection</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/streaming#live"> <code>async db.live&lt;T&gt;(tabel, callback,diff)</code></a></td>
<td scope="row" data-label="Description">Initiate a live query</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/streaming#subscribeLive"> <code>async db.subscribeLive&lt;T&gt;(queryUuid,callback)</code></a></td>
<td scope="row" data-label="Description">Register a callback for a running live query</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/streaming#kill"> <code>async db.kill(queryUuid)</code></a></td>
<td scope="row" data-label="Description">Kill a running live query</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#query"> <code>async db.query&lt;T&gt;(sql,vars)</code></a></td>
<td scope="row" data-label="Description">Runs a set of SurrealQL statements against the database</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#select"> <code>async db.select&lt;T&gt;(thing)</code></a></td>
<td scope="row" data-label="Description">Selects all records in a table, or a specific record</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#create"> <code>async db.create&lt;T,U&gt;(thing,data)</code></a></td>
<td scope="row" data-label="Description">Creates a record in the database</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#insert"> <code>async db.insert&lt;T,U&gt;(thing,data)</code></a></td>
<td scope="row" data-label="Description">Inserts one or multiple records in the database</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#update"> <code>async db.update&lt;T,U&gt;(thing,data)</code></a></td>
<td scope="row" data-label="Description">Updates all records in a table, or a specific record</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#merge"> <code>async db.merge&lt;T,U&gt;(thing,data)</code></a></td>
<td scope="row" data-label="Description">Modifies all records in a table, or a specific record</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#patch"> <code>async db.patch&lt;T,U&gt;(thing,data)</code></a></td>
<td scope="row" data-label="Description">Applies JSON Patch changes to all records in a table, or a specific record</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="/docs/sdk/javascript/core/data-querying#delete"> <code>async db.delete&lt;T,U&gt;(thing,data)</code></a></td>
<td scope="row" data-label="Description">Deletes all records, or a specific record</td>
</tr>
</tbody>
</table>
In this section, let's learn how to build a simple application using the SurrealDB JavaScript SDK. The
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
sidebar_position: 5
sidebar_label: Data Querying
title: JavaScript | SDK | Data Querying
sidebar_label: Run SurrealQL queries
title: JavaScript | SDK | Run SurrealQL queries
description: SurrealDB supports a number of methods for interacting with the database and performing CRUD operations.
---
import Label from "@components/shared/Label.astro";

# Data Querying
# Run SurrealQL queries

The methods below are used to interact with the database and perform CRUD operations. You can also use the `query` method to run [SurrealQL statements](/docs/surrealql/statements) against the database.

Expand Down
2 changes: 1 addition & 1 deletion src/content/doc-sdk-javascript/data-types.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 3
sidebar_label: Data Types
title: JavaScript | SDKs | Integration
description: The JavaScript SDK translates all datatypes native to SurrealQL into either datatypes native to JavaScript, or a custom implementation. This document describes all datatypes, and links to their respective documentation.
Expand Down
19 changes: 15 additions & 4 deletions src/content/doc-sdk-javascript/setup.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
---
sidebar_position: 3
sidebar_label: Getting Started
title: JavaScript | SDK | Getting Started
sidebar_position: 2
sidebar_label: Quick start
title: JavaScript | SDK | Quick start
description: SurrealDB supports a number of methods for connecting to the database and performing data queries.
---

# Getting Started
# Quick start

- Step 1: Install the SDK
- Step 2: Import the SDK
- Step 3: Initialize the SDK
- Step 4: Create a new connection
- Step 5: Authenticate users
- Step 6: Perform data queries

Using the TS starter project, we will walk you through the process of installing and importing the SDK into your project.



Before you can use this SDK for JavaScript regardless of your environment, you need to install and import it into your project. This guide will walk you through the process of installing and importing the SDK into your project.

Expand Down

0 comments on commit f6ef504

Please sign in to comment.