Git Product home page Git Product logo

array-simple-query's Introduction


Array Simple Query

A convenient lib to manipulate object in JavaScript arrays.
Explore the docs »

View Demo · Report Bug · Request Feature

About The Project

Convenient functions to query and change objects in a JavaScript array. It is useful to manipulate local storages mirroring a server database.

List of features

  • Get and object using queries.
  • Filter array objects using nested queries.
  • Use queries to delete and update objects inside the array.

Getting Started

Installation

$ npm i array-simple-query  --save

Usage

import * as ASQ from 'array-simple-query';

const books = [{ 'id': 1, 'title': 'English course', 'author': {first_name: 'Joe', last_name:'Doe'},       'year': 2009 },
            { 'id': 2, 'title': 'Italian course', 'author': {first_name: 'Pinco', last_name:'Pallino'}, 'year': 2010 },
            { 'id': 3, 'title': 'German course', 'author': {first_name: 'Max', last_name:'Musterman'}, 'year': 2009 },
            { 'id': 4, 'title': 'Portugues course', 'author': {first_name: 'Ciclano', last_name:'Silva'}, 'year': 2010 }];

// simple query
const englishBook =  ASQ.getObject(books, {'title':'English course'});

//nested query
const pallinosBook = ASQ.getObject(books, {'author.last_name':'Pallino'});

//negation
const nonGermanBooks = ASQ.filterObjects(books,{'!title': 'German course'});

//deletion
const positionOfDeletedElements = ASQ.deleteObjects(books, {'year': 2009});

Contributing

This package is in development.

Authors

  • Carlos E. Viol Barbosa

License

This project is licensed under the MIT License

array-simple-query's People

Contributors

cviolbarbosa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.