npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@s88d-puppy/dbal

v2.0.12

Published

Database Abstraction Layer for S88D Puppy Project

Downloads

37

Readme

[PKG-DBAL] Database Abstraction Layer

Required Environment Variables

CACHE_ADAPTER

  • dyanamodb

DB_ADAPTER

  • dyanamodb

MQ_ADAPTER

  • sqs local none

ROOT_DIRECTORY

  • For local development using local MQ_ADAPTER. Can be omitted for cloud deployment.

DYNAMODB_ENDPOINT

  • For local development. Can be omitted for cloud deployment.

TABLE_PREFIX

  • Will yield ${TABLE_PREFIX}_graph

Model Subclass Structure

'use strict'

const Model = require('@s88d-puppy/dbal')

class Entity extends Model {

    constructor() {
        
        super()
    
        this.attributes = {
            [attribute_name] : [
                'identifier',               // Creates index, implies uniqueness
                'foreign',                  // Creates a foreign key (id in another microservice)
                'namespace:field'           // Creates an identifier within a namespace (determined by field)
                'mutable',                  // Makes attribute updateable
                'format:email',
                'format:url',
                'format:slug',
                'format:json',
                'format:mobile',
                'in:value1,value2,value3'
            ]
            ...
        }
        
        this.edges = {
            [label_name]: [
                ordinality,         // 0 or 1
                cardinality         // 1 or N
            ]
            ...
        }
    
    }
    
    async beforeCreate(data) {

        data.key = 'value'

    }
    
    async afterCreate(record) {
        
        // Some logic
    
    }
    
    async beforeUpdate(data) {

        data.key = 'value'

    }
    
    async afterUpdate(data) {
        
        // Some logic
    
    }

}

module.exports = Entity

Model Class Functions

async getAll()
async getByIds(ids)
async getById(id)
async getByIdOrThrow(id)
async getByIdentifier(identifier, value)
async getByIdentifierWithinNamespace(identifier, value, namespace)
async getByForeignKey(foreign_key, value)
async getEdge(id, edge)
async create(data = {}, context = 'create', contextVars = {})
async linkEdge(id, edge_label, edge_id, data = {})
async unlinkEdge(id, edge_label, edge_id)
async updateById(id, data = {}, context = 'update', contextVars = {})
async deleteById(id, context = 'delete', contextVars = {})
async search(query, perPage=10, page=1, sortField, sortOrder)

Model Class Hooks

async beforeCreate(data)
async afterCreate(record)
async beforeUpdate(data)
async afterUpdate(record)

Attribute Formats

  • email
  • url
  • slug
  • json
  • mobile

Error Codes

  • MS1-MOD001: Invalid edge (:edge)
  • MS1-MOD002: Missing edge (:edge)
  • MS1-MOD003: Record not found (:label-:id)
  • MS1-MOD004: Validation error
  • MS1-MOD005: Cannot link more than :cardinality edges on :node-:edge
  • MS1-MOD006: Cannot link less than :ordinality edges on :node-:edge