akbr-poke

0.0.2 • Public • Published

poke

A little library for poking at objects like MongoDB docs. For node and the browser.

For a complete list of supported operators, see the spec or the code.

var doc = {
  name: "Aaron",
  age: 29,
  hair: {
    color: "brown",
    style: "short"
  }
}

poke.into(doc, path, options)

poke.into(doc, "name") // "Aaron"
poke.into(doc, "hair.color") // "brown"
poke.into(doc, "hair.color", {contain:true}) // {hair: {color:"brown", style:"short"}}

poke.query(doc, queries, projection)

poke.query(doc, {name:"Frank"}) // undefined
poke.query(doc, {"hair.color":"brown"}) // doc
poke.query(doc) // doc
poke.query(doc, {"age":{"$gt":21}}}) // doc
poke.query(doc, {name:"Aaron"}, {"hair.style":1}) // {hair: {style:"short"}}

poke.update(doc, updates)

poke.update(doc, {"$inc":{age:1}}) // doc.age is now 30
poke.update(doc, {"$set":{"hair.color":"pink"}}) // doc.hair.color is now "pink"

/akbr-poke/

    Package Sidebar

    Install

    npm i akbr-poke

    Weekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • akbr