Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@singlestore/client
Advanced tools
The SingleStore Client is a package designed to use SingleStore API in Node.js environments.
The SingleStore Client is a package designed to use SingleStore API in Node.js environments.
To install the @singlestore/client
package, run the following command:
npm install @singlestore/client
import { SingleStoreClient } from "@singlestore/client";
const client = new SingleStoreClient({ ai });
const workspace = client.workspace({
host: "<DATABASE_HOST>",
user: "<DATABASE_USER>",
password: "<DATABASE_PASSWORD>",
});
const database = await workspace.createDatabase({ name: "my_database" });
const database = await workspace.database("my_database");
const usersTable = await database.createTable({
name: "users",
columns: {
id: { type: "BIGINT", autoIncrement: true, primaryKey: true },
name: { type: "VARCHAR(32)" },
role: { type: "VARCHAR(32)" },
},
});
await usersTable.insert([
{ name: "User 1", role: "admin" },
{ name: "User 2", role: "visitor" },
]);
const users = await usersTable.find();
const admins = await usersTable.find({ where: { role: "admin" } });
await usersTable.update({ role: "admin" }, { name: "User 2" });
import { AI } from "@singlestore/ai";
import { SingleStoreClient } from "@singlestore/client";
const ai = new AI({ openAIApiKey: "<OPENAI_API_KEY>" });
const client = new SingleStoreClient({ ai });
This method returns found rows.
const results = await usersTable.vectorSearch(
{ prompt: "A 4k monitor", vectorColumn: "description_v" },
{ select: ["name", "description", "price"], limit: 1 },
);
This method returns a chat completion or a chat completion stream based on the prompt and vector search results.
const stream = await usersTable.createChatCompletion(
{ prompt: "Find a 4k monitor", vectorColumn: "description_v", stream: true },
{ select: ["name", "description", "price"], limit: 1 },
);
const onChunk: OnChatCompletionChunk = (chunk) => console.log(chunk);
const chatCompletion = await ai.chatCompletions.handleStream(stream, onChunk);
console.log(chatCompletion);
interface StoreDatabase {
name: "store_database";
tables: {
products: {
name: "products";
columns: {
id: number;
name: string;
description: string;
price: number;
category_id: number;
description_v: string;
};
};
categories: {
name: "categories";
columns: {
id: number;
name: string;
};
};
};
}
const client = new SingleStoreClient({ ai });
const workspace = client.workspace<{
databases: { store_database: StoreDatabase };
}>({
host: "<DATABASE_HOST>",
user: "<DATABASE_USER>",
password: "<DATABASE_PASSWORD>",
});
const database = workspace.database("store_database");
const products = await database.table("products").find({
select: ["id", "name", "description", "price", "category.name"],
join: [
{
table: "categories",
as: "category",
on: ["category_id", "=", "id"],
},
],
where: {
"category.id": 1,
"price": { gte: 500 },
},
orderBy: { price: "desc" },
limit: 5,
});
console.log(products);
FAQs
The SingleStore Client is a package designed for interacting with the SingleStore API in Node.js environments.
We found that @singlestore/client 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.
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.