Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Latest commit

 

History

History
73 lines (54 loc) · 1.35 KB

README.md

File metadata and controls

73 lines (54 loc) · 1.35 KB

Deprecation Notice

Deprecation notice: This project and codebase are not maintained. We might revisit this again in the future, but for now the code is read-only :)

Jouch

A couchdb 2.0 query parser, using jison

Installation

npm install --save jouch

Usage

PouchDB

import parse from 'jouch'
import PouchDB from 'pouchdb'
import pouchdb-find from 'pouchdb-find'

PouchDB.plugin(pouchdb-find)
const db = new PouchDB('/path/to/pouch')

const selector = parse('id != null')
db.find({
  selector: selector
}).then(res => {
  // results
})

CouchDB 2.0

// TODO: add couchdb usage example

Expressions

expression result
== $eq
!= $ne
>= $gte
<= $lte
> $gt
< $lt
and $and
or $or
not $not
has $elemMatch

e.g.

const selector = jouch('age >= 18 and skills has "javascript"')

would parse to

{ "$and": [
    { "age": {"$gte": 18}},
    { "$elemMatch": {"skills": {"$eq": "javascript"}}}
   ]
}

Lead Maintainer: Jonathan Bowers