![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@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.
The npm package @singlestore/client receives a total of 281 weekly downloads. As such, @singlestore/client popularity was classified as not popular.
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.