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

@deessejs/collections

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deessejs/collections

High-level abstraction layer built on top of Drizzle ORM

latest
npmnpm
Version
0.4.3
Version published
Maintainers
1
Created
Source

collections

@deessejs/collections

npm Version Bundle Size Tests Coverage License

High-level abstraction layer built on top of Drizzle ORM.

Requirements

  • TypeScript 5.0+
  • Drizzle ORM

Installation

# Install collections
npm install @deessejs/collections

# Or using pnpm
pnpm add @deessejs/collections

# Or using yarn
yarn add @deessejs/collections

Quick Start

import { collection, field, f } from '@deessejs/collections'

// Define a collection
const users = collection({
  slug: 'users',
  fields: {
    name: field({ fieldType: f.text() }),
    email: field({ fieldType: f.text() })
  }
})

Features

  • Collection API - Define database collections with a clean API
  • Hooks System - Lifecycle hooks for all CRUD operations
  • Type Safety - Full TypeScript support with inferred types
  • Drizzle Integration - Built on top of Drizzle ORM

Hooks

Execute custom logic at each stage of database operations:

const users = collection({
  slug: 'users',
  fields: {
    name: field({ fieldType: f.text() }),
    email: field({ fieldType: f.text() })
  },
  hooks: {
    beforeCreate: [async (context) => {
      // Validate or transform data before creating
      context.data.email = context.data.email.toLowerCase()
    }],
    afterCreate: [async (context) => {
      // Handle post-creation logic
      console.log(`Created user: ${context.result.id}`)
    }]
  }
})

Available Hooks

HookDescription
beforeOperationRuns before any operation
afterOperationRuns after any operation
beforeCreateRuns before create operation
afterCreateRuns after create operation
beforeUpdateRuns before update operation
afterUpdateRuns after update operation
beforeDeleteRuns before delete operation
afterDeleteRuns after delete operation
beforeReadRuns before read operation
afterReadRuns after read operation

Field Types

import { f } from '@deessejs/collections'

// Text field
field({ fieldType: f.text() })

// Number field
field({ fieldType: f.number() })

// Boolean field
field({ fieldType: f.boolean() })

// UUID field
field({ fieldType: f.uuid() })

// Timestamp field
field({ fieldType: f.timestamp() })

API Reference

collection()

Create a new collection definition.

const users = collection({
  slug: 'users',
  name: 'Users',
  fields: {
    name: field({ fieldType: f.text() })
  },
  hooks: {
    beforeCreate: [async (ctx) => { /* ... */ }]
  }
})

field()

Define a field in a collection.

const name = field({
  fieldType: f.text(),
  optional: false,
  default: 'default value'
})

createCollectionOperations()

Create CRUD operations for a collection.

import { createCollectionOperations } from '@deessejs/collections'

const operations = createCollectionOperations(
  collection,
  tableName,
  db,
  table,
  hooks
)

// Create
await operations.create({ data: { name: 'John' } })

// Read
await operations.findMany()

// Update
await operations.update({ where: { id: 1 }, data: { name: 'Jane' } })

// Delete
await operations.delete({ where: { id: 1 } })

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

  • Nesalia Inc.

Security

If you discover any security vulnerabilities, please send an e-mail to security@nesalia.com.

License

MIT License - see the LICENSE file for details.

FAQs

Package last updated on 04 Mar 2026

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