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

data-orbit

v1.0.2

Published

DataOrbit es una biblioteca para gestionar bases de datos JSON de forma intuitiva y eficiente en TypeScript.

Downloads

5

Readme

DataOrbit

DataOrbit es una biblioteca para gestionar bases de datos JSON de forma intuitiva y eficiente en TypeScript. Permite la creación, modificación, eliminación y consulta de datos utilizando un archivo JSON como almacenamiento persistente.

Instalación

Para instalar DataOrbit, puedes utilizar npm. Ejecuta el siguiente comando en tu terminal:

npm install data-orbit

Uso básico

Configuración inicial

Antes de usar DataOrbit, necesitas configurar tu base de datos. Aquí tienes un ejemplo de configuración básica:

import DataOrbit, { DataOrbitConfig } from 'dataorbit';

const config: DataOrbitConfig = {
    file: './database.json',
    encryptionKey: 'mySecretKey',
    tables: {
        users: {
            id: 'Text',
            name: 'Text',
            age: 'Number',
        },
        products: {
            id: 'Text',
            name: 'Text',
            price: 'Number',
        },
    },
    backups: [
        { interval: 5 }, 
    ],
};

const database = new DataOrbit(config);

Operaciones básicas

Una vez configurada la base de datos, puedes realizar operaciones básicas como insertar, eliminar, modificar y consultar datos. Aquí tienes algunos ejemplos:

// Insertar un nuevo usuario
database.insert('users', { id: '1', name: 'John Doe', age: 30 });

// Eliminar un producto
database.delete('products', 'id', '1');

// Modificar la información de un usuario
database.editInfo('users', 'id', '1', { age: 31 });

// Obtener información de un usuario específico
const specificUser = database.getRow('users', 'id', '1');

// Obtener todos los IDs de usuarios
const allUserIds = database.getColumn('users', 'id');

Backup automático

DataOrbit ofrece la posibilidad de realizar copias de seguridad automáticas de tu base de datos. Esto se configura durante la inicialización de la base de datos y se ejecuta periódicamente según el intervalo especificado.

database.startBackupService();

Métodos disponibles

DataOrbit proporciona varios métodos para interactuar con la base de datos. Aquí tienes una lista de los principales métodos disponibles:

  • insert(tableName: string, data: any): Inserta un nuevo registro en la tabla especificada.
  • delete(tableName: string, primaryKey: string, value: any): Elimina un registro de la tabla especificada utilizando la clave primaria.
  • editInfo(tableName: string, primaryKey: string, value: any, newData: any): Modifica la información de un registro existente en la tabla especificada.
  • getRow(tableName: string, primaryKey: string, value: any): any: Obtiene un registro específico de la tabla especificada utilizando la clave primaria.
  • getColumn(tableName: string, columnName: string): any[]: Obtiene todos los valores de una columna específica de la tabla especificada.
  • createTable(tableName: string, schema: TableSchema): Crea una nueva tabla con el esquema especificado.
  • dropTable(tableName: string): Elimina una tabla existente.

Conclusión

DataOrbit es una biblioteca simple pero poderosa para gestionar bases de datos JSON en TypeScript. Con su fácil configuración y su amplia gama de funciones, es ideal para proyectos pequeños y medianos que requieran una solución de almacenamiento de datos flexible y eficiente.


Un codigo, escrito por el equipo de crafty-labs