npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oldbitquery2

v0.0.1

Published

Bitquery is a JavaScript library that lets you query a BitDB node.

Downloads

2

Readme

Bitquery

Bitquery is a JavaScript library that lets you query a BitDB node.

Prerequiesites

Bitquery is a query engine that directly interfaces with a BitDB node. You must have access to a BitDB node through either a local or remote MongoDB URL.

This library is for connecting directly to a BitDB MongoDB instance, and is not for HTTP access. If you're looking for a public HTTP endpoint, this library is not what you're looking for. You can instead use the HTTP-based API endpoint at bitdb.network, which takes only a couple of minutes to get your app up and running.

Install

npm install --save bitquery

Usage

First initialize, and use the returned db object to make the query.

1. Using Promises

var bitquery = require('bitquery')
var bql = {
  "request": {
    "encoding": {
      "output.b0": "hex"
    },
    "find": {
      "output.b0": "6d02"
    },
    "sort": {
      "output.b1": 1
    },
    "limit": 50
  },
  "response": {
    "encoding": {
      "output.b0": "hex",
      "output.b1": "utf8",
      "output.b2": "hex"
    }
  }
}
bitquery.init().then(function(db) {
  db.read(bql).then(function(response) {
    console.log("Response = ", response)
  })
})

2. Using Async-Await

var bitquery = require('bitquery')
var bql = {
  "request": {
    "encoding": {
      "output.b0": "hex"
    },
    "find": {
      "output.b0": "6d02"
    },
    "sort": {
      "output.b1": 1
    },
    "limit": 50
  },
  "response": {
    "encoding": {
      "output.b0": "hex",
      "output.b1": "utf8",
      "output.b2": "hex"
    }
  }
};
(async function () {
  let db = await bitquery.init();
  let response = await db.read(bql);
  console.log("Response = ", response)
})();

Note: By default bitquery connects to mongodb://localhost:27017 so you don't need to configure anything if you set up BitDB without changing anything.

BitDB Query Language

BitDB Query Language is a meta query language that builds on top of MongoDB query language, which means it supports 100% of all MongoDB operations.

Learn more here: ___

Configuration

You can set the following two options:

  1. url: BitDB Node URL
  2. timeout: Request timeout

1. url

Select the BitDB URL to connect to.

bitquery.init({
  url: "mongodb://localhost:27017"
}).then(function(db) {
  ...
})

2. timeout

Set request timeout in milliseconds. All BitDB requests will time out after this duration.

bitquery.init({
  timeout: 20000
}).then(function(db) {
  ...
})

Bitdb Query Language

The query language is a meta language built on top of MongoDB's own query language, which means 100% of MongoDB's queries are supported.

Top level attributes:

  • v: version (default is 2)
  • e: encoding (declare the encoding of each query attribute)
  • q: query (MongoDB query)