Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
surrealised
Advanced tools
A basic SurrealDB Client Library for NodeJS.
yarn add surrealised@latest
const Surrealised = require('surrealised');
let surrealClient = new Surrealised();
let results = await surrealClient.query('SELECT * FROM users');
Configuration is set either via Environment Variables, or via the class initialisation.
SURREAL_DB_HOST=http://localhost:8000/rpc
SURREAL_DB_USER=your_user
SURREAL_DB_PASSWORD=your_password
SURREAL_DB_NAMESPACE=your_namespace
SURREAL_DB_DATABASE=your_database
SURREAL_DB_DEBUG=false #show debug output in the console logs
const Surrealised = require('surrealised');
let surrealClient = new Surrealised({
debug: true,
connection: {
host: 'http://localhost:8000/rpc',
user: 'your_user',
password: 'your_password',
namespace: 'your_namespace',
database: 'your_database'
}
});
// The rest of your code
I have neatened up the methods to make them more intuitive and easier to use (akin to other SQL libraries or ORMs out there)
Return the first row of the last query given.
let result:User = await surrealClient.queryOne<User>('SELECT * FROM users WHERE email = $email', {
email: 'user@company.com'
});
Return all the results from the last query given.
let results:User[] = await surrealClient.queryMany<User>('SELECT * FROM users WHERE email contains $domain', {
domain: 'company.com'
});
Fetch a record via it's ID field
let user:User = await surrealClient.fetch<User>('user:bob');
Fetch all records from a table
let users:User[] = await surrealClient.fetchMany<User>('user');
Create a record
let user:User = await surrealClient.create<User>('user', {
name: 'Bob',
email: 'bob@company.com',
age: 30
});
Update a record, merges if it exists, create a new record if it doesn't
let user:User = await surrealClient.update<User>('user:bob', {
age: 31
});
Delete a record
await surrealClient.delete('user:bob');
// #RIP Bob :(
Execute a native surrealdb.js query, will return an array of results for each query in the query string.
let results = await surrealClient.execute('SELECT * FROM users');
If you want to instantiate the class once and use it throughout your application, keeping the same connection, you can construct a "master class" to handle it. This is not recommended due to SurrealDBs use of Websockets to maintain a connection, and the fact that NodeJS is single threaded, but it is possible if you have a slow(ish) influx of instructions.
// surrealClient.ts
const Surrealised = require('surrealised');
let surrealClient = new Surrealised();
module.exports = surrealClient;
// index.ts (or whatever)
const surrealClient = require('./surrealClient');
let users = surrealClient.queryMany<User>('SELECT * FROM users');
FAQs
Another SurrealDB Library for NodeJS
The npm package surrealised receives a total of 5 weekly downloads. As such, surrealised popularity was classified as not popular.
We found that surrealised demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.