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

ndynamo-builder

v1.1.8

Published

Generación de un query builder para poder reutilizar en las consultas a DynamoDB.

Downloads

5

Readme

ndynamo-builder

Esta librería permite realizar queries sobre DynamoDB de una manera más amigable. Utiliza nbased, implementada para NaranjaX.

Características actuales:

  • Operaciones sobre colecciones: add, update, delete, query y scan.
  • Expresiones de filtro y comparación: begins_with, contains, attribute_type, if, attribute_exists, attribute_not_exists, in, projection, limit.
  • Eliminación de atributos.
  • Definir el uso de indices secundarios globales.

Instalación

Usando npm

  npm install ndynamo-builder

Uso/Ejemplos

Importar

import { DynamoBuilder } from "ndynamo-builder";

const testDB = new DynamoBuilder("DYNAMO_TABLE");

Items

Add

testDB.add({ name: 'john', age: 40 });

Get

testDB.get({ name: 'john' });

Query

testDB.query('name', 'john');

Update

testDB.update({ name: 'john' }, { age: 28 })

Scan

testDB.scan();

Delete

testDB.delete({ name: "john" });

Conditional Queries

Chequear si un atributo existe

const newUser = { name: "abel", age: 34 };

testDB.exists('name').add(newUser);
testDB.exists( ['name', 'age'] ).add(newUser);

testDB.notExists('name').add(newUser);
testDB.notExists( ['name', 'age'] ).add(newUser);

Chequear si un atributo existe

const key = { name: "hector" };

testDB.add({ name: "hector", last_connection: 50, age: 10, friends: { nice: 0, bad: 10 } });

// Delete
testDB
  .if('last_connection', '>', 30 )
  .if('last_connection', '<', 100)
  .if('age', '<>', 90) // different than
  .delete(key);

// Update
testDB
  .if('last_connection', '=', 50)
  .if('friends.bad', '>=', 0)
  .if('age', '<=', 10)
  .update(key, { candy: 1 });

Attribute functions

beginsWith

Busca un substring en el comienzo del valor de un atributo.

// Updates user if nickname attribute begins with a 'm'
testDB
    .where('nickname', 'beginsWith', 'm')
    .update(key, { nickname: "lol" });

contains

Puede verificar un elemento en un conjunto o buscar una subcadena dentro de una cadena

// Updates user if nickname contains 'lol'
testDB
    .where('nickname', 'contains', 'lol')
    .update(key, { fun: true });

typeIs

Evalúa el tipo de dato del atributo.

// Updates user momo if his friends attribute is N (number)
testDB
    .where('friends', 'typeIs', 'N')
    .update(key, { friends: 0 });

inList

Busca un atributo dentro de una lista.

// Gets user named 'abel' if he has a friend named 'abdu' or 'chris'
testDB
    .inList('friends', [ 'abdu', 'chris' ])
    .query('name', '=', 'abel');

Remove attribute

Elima un atributo del item.

testDB.removeAttribute(key, [ 'last_connection' ]);

Projections

Puede seleccionar el o los atributos que quiere obtener del resultado de la operación get, query o scan.

// one attribute
testDB
    .project('name')
    .query('id', '=', 1);

testDB
    .project(['name'])
    .get({ id: 1 });

// more attributes
testDB
    .project(['name', 'last_connection'])
    .scan();

Limit

Limitar la cantidad de resultados devueltos en la consulta.

testDB
    .limit(2)
    .query('id', '=', 1);

Global secondary indexes

Puede definir el uso de un indice secundario.

testDB
    .useIndex('age')
    .query('age', '=', 20);

Tests

Los test se encuentran en la carpeta "./test"

Para poder correr deben tener DynamoDB corriendo localmente

  npm run test

Usado por

Este proyecto surge de:

  • NaranjaX - Ranty