# miniquery

> Simplest object querying tool

Latest version **1.1.2** (published 2016-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install miniquery
pnpm add miniquery
yarn add miniquery
bun add miniquery
```

Provides the command `miniquery`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2016-08-05 |
| First published | 2014-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Nicolas Froidure |
| Maintainers | nfroidure, gplancke |
| Keywords | object, query, values |

## Links

- npm: https://www.npmjs.com/package/miniquery
- Repository: https://github.com/SimpliField/miniquery
- Issues: https://github.com/SimpliField/miniquery/issues
- npm.io page: https://npm.io/package/miniquery

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) ^2.8.1

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2016-08-05
- 1.1.1 — 2015-06-25
- 1.1.0 — 2015-06-02
- 1.0.0 — 2014-12-22

## README

# miniquery

`miniquery` allows you to query objects for a given path and returns you an
 `Array` of values matching.

[![NPM version](https://badge.fury.io/js/miniquery.png)](https://npmjs.org/package/miniquery) [![Build status](https://secure.travis-ci.org/SimpliField/miniquery.png)](https://travis-ci.org/SimpliField/miniquery) [![Dependency Status](https://david-dm.org/SimpliField/miniquery.png)](https://david-dm.org/SimpliField/miniquery) [![devDependency Status](https://david-dm.org/SimpliField/miniquery/dev-status.png)](https://david-dm.org/SimpliField/miniquery#info=devDependencies) [![Coverage Status](https://coveralls.io/repos/SimpliField/miniquery/badge.png?branch=master)](https://coveralls.io/r/SimpliField/miniquery?branch=master) [![Code Climate](https://codeclimate.com/github/SimpliField/miniquery.png)](https://codeclimate.com/github/SimpliField/miniquery)

## Installation

First install `miniquery` in you project:
```sh
npm install --save miniquery
```

## Getting started

Then, use it:

```js
var miniquery = require('miniquery');
var assert = require('assert');

var fruits = [{
  name: 'orange'
  count: 2,
  colors: ['orange']
}, {
	name: 'banana',
  count: 0,
  colors: ['yellow', 'white']
}, {
	name: 'kiwi',
  count: 8,
  colors: ['brown', 'green']
}];

var orangeColor = miniquery('0.colors.0', [fruits]);
assert.deepEqual(orangeColor, ['orange']);

var counts = miniquery('*.count', [fruits]);
assert.deepEqual(counts, [2, 0, 8]);

var colors = miniquery('colors.#', fruits);
assert.deepEqual(colors, ['orange', 'yellow', 'white', 'brown', 'green']);
```

Note that `miniquery` always returns an `Array` even if there is no or only one
 result.

## CLI usage

Install miniquery globally:
```sh
sudo npm install -g miniquery
```

Then, simply run your queries on one or more JSON files. Let's assume we want
 to list distinct keywords on all of our NodeJS projects :
```sh
miniquery "keywords.*" ~/projects/*/package.json -p | uniq
# minimatch
# gulp
# svg
# gulp
# gulp-plugin
# (...)
# github
# REST
# HTTP
# server
# web
#services
```

Get every available options by running:
```sh
miniquery -h

# Usage: miniquery [options] <query> <file ...>
#
# Options:
#
#   -h, --help       output usage information
#   -V, --version    output the version number
#   -v, --verbose    tell me everything!
#   -j, --json       output JSON
#   -p, --primitive  print primitives only
```

## API

### values:Array miniquery(path:String, objs:Array)
Return the `values` matching the given `path` for the objects contained in
 `objs`.

## Contribute

Feel free to submit us your improvements. To do so, you must accept to publish
 your code under the MIT license.

To start contributing, first run the following to setup the development
 environment:
```sh
git clone git@github.com:SimpliField/miniquery.git
cd miniquery
npm install
```

Then, run the tests:
```sh
npm test
```

## Stats
[![NPM](https://nodei.co/npm/miniquery.png?downloads=true&stars=true)](https://nodei.co/npm/miniquery/)
[![NPM](https://nodei.co/npm-dl/miniquery.png)](https://nodei.co/npm/miniquery/)

---
_Source: https://npm.io/package/miniquery · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
