
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
universal-db-layer
Advanced tools
Cross-platform unified database layer with auto-environment detection and Prisma-like API
A cross-platform unified database layer that automatically detects your runtime environment and uses the appropriate storage backend with a familiar Prisma-like API.
npm install unified-db-layer
For React Native projects, also install:
npm install @react-native-async-storage/async-storage
import { UnifiedDB } from "unified-db-layer";
// Define your data models
const db = new UnifiedDB({
models: {
User: {
fields: {
id: { type: "string", primaryKey: true },
name: { type: "string", required: true },
email: { type: "string", required: true },
age: { type: "number", default: 0 },
createdAt: { type: "date", default: "now" },
},
},
Post: {
fields: {
id: { type: "string", primaryKey: true },
title: { type: "string", required: true },
content: { type: "string", required: true },
authorId: { type: "string", required: true },
published: { type: "boolean", default: false },
},
},
},
});
// Initialize the database
await db.init();
// Use the Prisma-like API
const user = await db.user.create({
name: "John Doe",
email: "john@example.com",
age: 30,
});
const users = await db.user.findMany({
where: { age: { gte: 18 } },
orderBy: { name: "asc" },
take: 10,
});
const post = await db.post.create({
title: "Hello World",
content: "This is my first post!",
authorId: user.id,
published: true,
});
Platform | Storage Backend | Capacity | Persistence |
---|---|---|---|
Browser | IndexedDB (preferred) | ~50MB+ | Until cleared |
Browser | localStorage (fallback) | ~5-10MB | Until cleared |
Node.js | File System | Disk space | Permanent |
Electron | File System | Disk space | Permanent |
React Native | AsyncStorage | Platform dependent | Until uninstalled |
The library automatically detects your environment and chooses the best available storage backend.
// Complex queries with method chaining
const results = await db.user
.where("age", ">", 18)
.where("email", "contains", "@company.com")
.orderBy("createdAt", "desc")
.limit(50)
.findMany();
// Add custom logic to database operations
db.addHook("beforeCreate", (modelName, data) => {
data.createdBy = getCurrentUserId();
return data;
});
db.addHook("afterUpdate", (modelName, data) => {
console.log(`Updated ${modelName}:`, data.id);
});
// Backup your data
const backup = await db.export();
// Restore from backup
await db.import(backup, { clearFirst: true });
We welcome contributions! Please see our Contributing Guide for details.
# Clone the repository
git clone https://github.com/yourusername/unified-db-layer.git
cd unified-db-layer
# Install dependencies
npm install
# Run tests
npm test
# Build the package
npm run build
# Run linting
npm run lint
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
MIT © Your Name
FAQs
Cross-platform unified database layer with auto-environment detection and Prisma-like API
The npm package universal-db-layer receives a total of 0 weekly downloads. As such, universal-db-layer popularity was classified as not popular.
We found that universal-db-layer 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.