Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electrodb

Package Overview
Dependencies
Maintainers
1
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electrodb

A library to more easily create and interact with multiple entities and heretical relationships in dynamodb

  • 2.10.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
456K
increased by70.04%
Maintainers
1
Weekly downloads
 
Created

What is electrodb?

ElectroDB is a DynamoDB library that simplifies the process of defining and interacting with DynamoDB tables. It provides a high-level abstraction for defining entities, managing relationships, and performing CRUD operations, making it easier to work with DynamoDB's complex data modeling and querying capabilities.

What are electrodb's main functionalities?

Entity Definition

This feature allows you to define an entity with its attributes and indexes. The code sample demonstrates how to create a User entity with attributes like userId, name, and email, and a primary index.

const { Entity } = require('electrodb');

const UserEntity = new Entity({
  model: {
    entity: 'User',
    version: '1',
    service: 'UserService'
  },
  attributes: {
    userId: { type: 'string', required: true },
    name: { type: 'string', required: true },
    email: { type: 'string', required: true }
  },
  indexes: {
    primary: {
      pk: { field: 'pk', composite: ['userId'] },
      sk: { field: 'sk', composite: [] }
    }
  }
});

CRUD Operations

This feature provides methods for performing CRUD operations on the defined entities. The code sample shows how to create, read, update, and delete a user entity.

const user = await UserEntity.put({
  userId: '123',
  name: 'John Doe',
  email: 'john.doe@example.com'
}).go();

const fetchedUser = await UserEntity.get({ userId: '123' }).go();

const updatedUser = await UserEntity.update({ userId: '123' })
  .set({ name: 'Jane Doe' })
  .go();

const deletedUser = await UserEntity.delete({ userId: '123' }).go();

Querying

This feature allows you to perform complex queries on your entities. The code sample demonstrates how to query the User entity using the primary index.

const users = await UserEntity.query.primary({ userId: '123' }).go();

Relationships

This feature allows you to define and manage relationships between different entities. The code sample shows how to fetch a user along with their related orders using the Service class.

const { Service } = require('electrodb');

const UserService = new Service({
  User: UserEntity,
  Order: OrderEntity
});

const userWithOrders = await UserService.User.get({ userId: '123' }).include(OrderEntity).go();

Other packages similar to electrodb

Keywords

FAQs

Package last updated on 03 Oct 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc