New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

crud-from-array

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crud-from-array

Clase para crear crud de un array, fix documentacion

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Crud From Array

Usamo una clase para hacer operaciones CRUD sobre un array.

Esto sirve para hacer mocks o pruebas en formularios.

Setup

import {CrudFromArray} from 'crud-from-array';

let arregloPersonas = [
    {id: 1, nombre: 'Juan'},
    {id: 2, nombre: 'Pablo'},
    {id: 3, nombre: 'Leo'},
    {id: 4, nombre: 'Mariana'},
    {id: 5, nombre: 'Daniela'},
    {id: 6, nombre: 'Jesus'},
    {id: 7, nombre: 'María'},
    {id: 8, nombre: 'Luis'},
    {id: 9, nombre: 'José'},
    {id: 10, nombre: 'Fabi'},
];

let persona =  new CrudFromArray(arregloPersonas, 'id');

cdn

Uso con unpkg:

import {CrudFromArray} from 'https://unpkg.com/crud-from-array';

Crear datos (post)

Para agregar datos a una tabla necesitamos hacer un post:

persona.post({nombre: 'jj', id: 11});

notar: Que al ser un arreglo que manejamos, se tiene que dar los ids manualmente

Leer datos

Contamos con dos opciones: get and list.

Get

//obtenemos la persona con id = 2
persona.get(2);

List

Regresa la lista de todos los items del array

//regresa los primeros 10 registros del array
persona.list()


//regresa un sub array con 5 elementos inicializando desde la posicion 4
const offset = 4;
const limit = 5; 
persona.list(offset, limit);

Actualizar datos

Para actualizar los registro del array usamos

//actualizamos el item con id 1 con el objecto {nombre: 'coque'}
persona.update(1, {nombre: 'coque'});

Delete

Eliminamos el elemnto del array con id dado

//eliminamos el item con id = 2
persona.delete(2);

Keywords

js

FAQs

Package last updated on 23 Feb 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