New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

veddb-client

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

veddb-client

Official JavaScript/TypeScript client for VedDB v0.2.0 - MongoDB-like API with verified wire protocol

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

vedDB Client v0.2.0

Modern JavaScript/TypeScript client for VedDB v0.2.0 with Mongoose-like API

npm version License: MIT Node.js Version

🚀 Features

  • Mongoose-like API - Familiar Schema and Model pattern
  • TypeScript Support - Full type definitions included
  • Query Builder - Fluent, chainable queries
  • Connection Pooling - Automatic connection management
  • Validation - Schema-based validation
  • Hooks - Pre/post middleware support
  • Modern ES Modules - Clean import/export syntax

📦 Installation

npm install veddb
# or
yarn add veddb
# or
pnpm add veddb

🏃 Quick Start

Basic Usage

import veddb, { Schema, model } from 'veddb';

// Connect to VedDB server
await veddb.connect('localhost', 50051);

// Define a schema
const userSchema = new Schema({
  name: { type: String, required: true },
  email: { type: String, required: true, unique: true },
  age: { type: Number, min: 0, max: 120 },
  createdAt: { type: Date, default: Date.now }
});

// Create a model
const User = model('User', userSchema);

// Create a document
const user = await User.create({
  name: 'Alice',
  email: 'alice@example.com',
  age: 30
});

// Find documents
const users = await User.find({ age: { $gt: 25 } });

// Update
await User.updateOne({ name: 'Alice' }, { age: 31 });

// Delete
await User.deleteOne({ name: 'Alice' });

TypeScript Usage

import veddb, { Schema, model, Document } from 'veddb';

interface IUser extends Document {
  name: string;
  email: string;
  age: number;
  createdAt: Date;
}

const userSchema = new Schema<IUser>({
  name: { type: String, required: true },
  email: { type: String, required: true },
  age: { type: Number },
  createdAt: { type: Date, default: Date.now }
});

const User = model<IUser>('User', userSchema);

const user: IUser = await User.findOne({ email: 'alice@example.com' });

🔧 API Reference

Connection

// Connect with options
await veddb.connect('localhost', 50051, {
  poolSize: 10,
  auth: {
    username: 'admin',
    password: 'password'
  },
  tls: {
    enabled: true
  }
});

// Connection events
veddb.connection.on('connected', () => console.log('Connected!'));
veddb.connection.on('error', (err) => console.error(err));

// Disconnect
await veddb.disconnect();

Schema Definition

const schema = new Schema({
  // Basic types
  name: String,
  age: Number,
  active: Boolean,
  birthday: Date,
  
  // With options
  email: {
    type: String,
    required: true,
    unique: true,
    lowercase: true,
    trim: true
  },
  
  // Nested objects
  address: {
    street: String,
    city: String,
    zip: String
  },
  
  // Arrays
  tags: [String],
  friends: [{ type: Schema.Types.ObjectId, ref: 'User' }],
  
  // Default values
  createdAt: { type: Date, default: Date.now },
  
  // Custom validators
  password: {
    type: String,
    validate: {
      validator: (v) => v.length >= 8,
      message: 'Password must be at least 8 characters'
    }
  }
});

// Add methods
schema.method('getFullName', function() {
  return `${this.firstName} ${this.lastName}`;
});

// Add statics
schema.static('findByEmail', function(email) {
  return this.findOne({ email });
});

// Add hooks
schema.pre('save', function(next) {
  this.updatedAt = new Date();
  next();
});

schema.post('save', function(doc) {
  console.log('Document saved:', doc._id);
});

Model Operations

// Create
const user = new User({ name: 'Bob', age: 25 });
await user.save();

// OR
await User.create({ name: 'Charlie', age: 35 });
await User.insertMany([{ name: 'Dave' }, { name: 'Eve' }]);

// Read
const all = await User.find();
const filtered = await User.find({ age: { $gte: 30 } });
const one = await User.findOne({ name: 'Alice' });
const byId = await User.findById('507f1f77bcf86cd799439011');

// Update
await User.updateOne({ name: 'Bob' }, { age: 26 });
await User.updateMany({ age: { $lt: 30 } }, { status: 'young' });
await User.findByIdAndUpdate(id, { age: 27 }, { new: true });

// Delete
await User.deleteOne({ name: 'Bob' });
await User.deleteMany({ age: { $lt: 18 } });
await User.findByIdAndDelete(id);

// Count
const count = await User.countDocuments({ age: { $gt: 30 } });
const exists = await User.exists({ name: 'Alice' });

Query Builder

// Chainable queries
const users = await User
  .find({ status: 'active' })
  .where('age').gt(25).lt(50)
  .where('city').equals('NYC')
  .sort({ age: -1, name: 1 })
  .limit(10)
  .skip(5)
  .select('name email age')
  .exec();

// Query operators
query.where('age').gt(25);        // Greater than
query.where('age').gte(25);       // Greater than or equal
query.where('age').lt(50);        // Less than
query.where('age').lte(50);       // Less than or equal
query.where('name').equals('Alice');
query.where('status').in(['active', 'pending']);
query.where('city').ne('NYC');    // Not equal
query.where('tags').all(['javascript', 'nodejs']);
query.where('name').regex(/^A/);

// Sorting
query.sort({ age: -1 });          // Descending
query.sort('name');                // Ascending
query.sort('-age name');           // Multiple fields

// Pagination
query.limit(20);
query.skip(40);

// Field selection
query.select('name email');        // Include
query.select('-password -secret'); // Exclude

Aggregation

const results = await User.aggregate([
  { $match: { age: { $gt: 25 } } },
  { $group: {
    _id: '$city',
    avgAge: { $avg: '$age' },
    count: { $sum: 1 }
  }},
  { $sort: { count: -1 } },
  { $limit: 10 }
]);

🐳 Docker Support

VedDB Server is available as a Docker image:

docker pull mihirrabariii/veddb:latest
docker run -d -p 50051:50051 mihirrabariii/veddb:latest

Then connect from your app:

await veddb.connect('localhost', 50051);

📖 Examples

See the examples directory for more:

📄 License

MIT © Mihir Rabari

🤝 Contributing

Contributions are welcome! Please open an issue or PR.

📧 Contact

Keywords

veddb

FAQs

Package last updated on 30 Dec 2025

Did you know?

Socket

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.

Install

Related posts