Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

surrealised

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

surrealised - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

20

dist/index.d.ts

@@ -21,2 +21,3 @@ import * as surrealdb_js_script_types from 'surrealdb.js/script/types';

private limitClause?;
variables: Record<string, any>;
constructor(table: string);

@@ -104,3 +105,3 @@ /**

*/
queryOne<T>(params: Record<string, any>): Promise<T>;
queryOne<T>(params?: Record<string, any>): Promise<T>;
/**

@@ -110,3 +111,18 @@ * Execute the query and return many rows

*/
queryMany<T>(params: Record<string, any>): Promise<T[]>;
queryMany<T>(params?: Record<string, any>): Promise<T[]>;
/**
* Add a variable to the query for execution.
* @param key
* @param value
*/
addVariable(key: string, value: any): this;
/**
* Remove a variable from the query
* @param key
*/
removeVariable(key: string): this;
/**
* Clear all variables from the query
*/
clearVariables(): this;
}

@@ -113,0 +129,0 @@

@@ -44,2 +44,3 @@ var __defProp = Object.defineProperty;

limitClause = void 0;
variables = {};
constructor(table) {

@@ -227,4 +228,8 @@ this.table = table;

let q = this.build();
let variables = {
...this.variables,
...params
};
const surreal = new SurrealClient();
return await surreal.queryOne(q, params);
return await surreal.queryOne(q, variables);
}

@@ -238,4 +243,32 @@ /**

const surreal = new SurrealClient();
return await surreal.queryMany(q, params);
let variables = {
...this.variables,
...params
};
return await surreal.queryMany(q, variables);
}
/**
* Add a variable to the query for execution.
* @param key
* @param value
*/
addVariable(key, value) {
this.variables[key] = value;
return this;
}
/**
* Remove a variable from the query
* @param key
*/
removeVariable(key) {
delete this.variables[key];
return this;
}
/**
* Clear all variables from the query
*/
clearVariables() {
this.variables = {};
return this;
}
};

@@ -242,0 +275,0 @@ var SurrealQueryBuilder_default = SurrealQueryBuilder;

2

package.json
{
"name": "surrealised",
"version": "0.2.9",
"version": "0.2.10",
"description": "Another SurrealDB Library for NodeJS",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -309,3 +309,3 @@ # Surrealised

Executes the query and returns a single row or none. It requires a parameter object for any placeholders within the query.
Executes the query and returns a single row or none. It can take a parameter object for any variables within the query.

@@ -325,3 +325,42 @@ **Example:**

```javascript
query.select("id", "name").where("active = true").queryMany<{ id: string, name: string }>({});
query.select("id", "name").where("active = true").queryMany<{ id: string, name: string }>();
```
## Variables
You can access the `variables` dictionary directly to modify, remove or add variables to the query.
```javascript
query.variables = {
user: "user:123456",
date: new Date(),
count: 10
}
```
I have also included some helper functions to make this easier:
### addVariable(key: string, value: any)
Add a variable to be passed to the query. If the variable already exists, it will be overwritten.
```javascript
query.addVariable("user", "user:123456")
//... other operations
query.where('created_by = $user')
```
### removeVariable(key: string)
Remove a variable from the query.
```javascript
query.removeVariable("user")
```
### clearVariables()
Clear all variables from the query.
```javascript
query.clearVariables()
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc