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

dynamola

v1.4.5

Published

DynamoDB easy library for Lambda functions.

Downloads

5

Readme

dynamola

NPM Version

DynamoDB easy library for Lambda functions.

Documentación completa en https://github.com/javichur/dynamola/blob/master/docs/index.md

Dynamola incluye métodos sencillos para

  • [x] Buscar elementos en una tabla DynamoDB (por Clave de Partición, por Clave de Ordenación, por Índice Local Secundario (LSI), Por Índice Global Secundario (GSI), por rango, por Clave de Ordenación que "empieza por", etc...).
  • [x] Obtener valor máximo de la Clave de Ordenación de una tabla o de un LSI.
  • [x] Añadir elementos en una tabla DynamoDB.
  • [x] Borrar elementos de una tabla DynamoDB.
  • [x] Actualizar un elemento de una tabla DynamoDB.
  • [x] Incrementar el valor de un atributo de un elemento, de una tabla DynamoDB.
  • [x] Crear tablas sencillas, con o sin Clave de Ordenación.
  • [x] Crear tablas sencillas, con o sin Índice Local Secundario (LSI).
  • [x] Crear tablas sencillas, con o sin Índice Global Secundario (GSI).

Ejemplo de uso


const Dynamola = require('dynamola');
let myDb = new Dynamola("nombre-tabla-en-dynamodb", "nombre-primary-key-en-tabla-dynamodb", null);

myDb.getItem(userID).then((data) => {
    if(!data){
        // item no existe
    }
    else {
        // item devuelto OK
    }
})
.catch((err) => {
    // error al acceder a dynamodb
});

Configuración inicial

  1. Crea tu tabla DynamoDB desde https://console.aws.amazon.com/dynamodb, indicando nombre de la tabla, nombre de la clave de partición (Partition Key) y opcionalmente: el nombre de la clave de ordenación (Sort Key), Índices Secundarios Locales (LSI).

  2. Opciones de acceso: a. Si vas a acceder a la tabla DynamoDB desde AWS (por ejemplo, desde una función AWS Lambda), crea una política de seguridad (https://console.aws.amazon.com/iam/home#/policies), que tenga acceso limitado a tu tabla DynamoDB. A continuación, añade la política recién creada al rol de ejecución de la función AWS Lambda (https://console.aws.amazon.com/iam/home?#/roles).Ejemplo de política de seguridad:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "dynamodb:PutItem",
                "dynamodb:DeleteItem",
                "dynamodb:GetItem",
                "dynamodb:Scan",
                "dynamodb:Query",
                "dynamodb:UpdateItem"
            ],
            "Resource": "<ARN de tu tabla DynamoDB>"
        }
    ]
}

b. Si quieres acceder a la tabla DynamoDB desde fuera de Amazon Web Services, puedes utilizar un fichero de credenciales compartidas (https://docs.aws.amazon.com/es_es/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html). Este método se usa por ejemplo en los tests de este módulo.

Tests con DynamoDB Local

Puedes probar en local descargando la herramienta "DynamoDB Local" (https://docs.aws.amazon.com/es_es/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html):

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

En windows:
java -D"java.library.path"=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

Conceptos

  1. Clave de Partición (Partition Key).
  2. Clave de Ordenación (Sort Key).
  3. Clave Principal Simple (Simple Primary Key). Formada solo por Clave de Partición.
  4. Clave Principal Compuesta (Composite Primary Key). Formada por una Clave de Partición y una Clave de Ordenación.
  5. Índice Secundario Local (LSI). Un índice que tiene la misma Clave de Partición que la tabla base, pero una clave de ordenación diferente.
  6. Índice Secundario Global (GSI). Un índice con una clave de partición y opcionalmente una clave de ordenación que pueden diferir de las claves de la tabla base.

Proyectos de ejemplo que usa Dynamola para leer y escribir en DynamoDB de AWS

https://github.com/javichur/alexa-skill-clean-code-template

https://github.com/javichur/Alexa-Skill-Lavaplatos

https://github.com/javichur/alexa-skill-nevera-estado/