
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
@dan-schel/db
Advanced tools
Provides a common API for working with MongoDB or an in-memory database.
Provides a common API for working with MongoDB or an in-memory database, with a migration system and type-safety. This means you can use MongoDB in prod, an in-memory database while unit testing, and whichever you prefer for local development.
Every time your app starts, you'll want to create a database connection, and immediately run the migrations.
import type { Migration } from "@dan-schel/db";
// Empty to start (see docs/writing-database-migrations.md).
const migrations: Migration[] = [];
const db = createDb();
await db.runMigrations(migrations);
The implementation of createDb()
depends on whether you're using MongoDB or an in-memory database.
For MongoDB, you'll need to create a MongoClient
using the mongodb
package and pass it along to MongoDatabase
.
import { MongoDatabase } from "@dan-schel/db";
import { MongoClient } from "mongodb";
function createDb() {
// The connection string for the MongoDB server.
const connectionString =
"mongodb://username:password@localhost:27017/?authMechanism=DEFAULT";
// Which database within the MongoDB server to use.
const databaseName = "my-project";
const client = new MongoClient(connectionString);
await client.connect();
return new MongoDatabase(client, databaseName);
}
For an in-memory database, things are a little simpler:
import { InMemoryDatabase } from "@dan-schel/db";
function createDb() {
return new InMemoryDatabase();
}
Now that your connection is established, you'll want to start working with some data:
FAQs
Provides a common API for working with MongoDB or an in-memory database.
The npm package @dan-schel/db receives a total of 173 weekly downloads. As such, @dan-schel/db popularity was classified as not popular.
We found that @dan-schel/db demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.