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

ak-rest

v0.0.1

Published

minimalistic Akiban REST driver for node.js

Downloads

3

Readme

Akiban REST Client for Node.js

A minimalistic Akiban client for node.js inspired by the nano driver for couchdb.

Installation

  1. install npm
  2. npm install ak-rest

Getting Started

To connect to Akiban:

var akiban = require('ak-rest')('http://localhost:8091/v1');

In node-rest-akiban the callback function receives always three arguments:

  • err - the error, if any
  • body - the http response body from Akiban, if no error.
  • header - the http response header from Akiban, if no error

A simple but complete example using callbacks is:

var akiban = require('ak-rest')('http://localhost:8091/v1');

// create a new model based on a JSON doc
model_doc = { "name" : "padraig" }
akiban.model.create('padraig', model_doc, function(err, header, body) {
  if (err) {
    console.log(err);
  } else {
    console.log(header);
    console.log(body);
  }
});

If you run this example(after starting Akiban) you will see:

{ 'content-type': 'application/json',
  'transfer-encoding': 'chunked',
  'status-code': 200,
  uri: 'http://localhost:8091/v1/model/parse/test.padraig?create=true' }
{ entities: 
   { padraig: 
      { entity: 'd6928c9b-168c-46df-ba3e-2a466acac221',
        attributes: [Object] } } }

Model Functions

model.create(name, json_doc, [callback])

Create a model called name from a JSON document and instantiate it.

json_doc = { "id": 657, "value": "this is some data" }
akiban.mode.create('t1', json_doc, function(err, body) {
  if (!err) {
    console.log(body);
  }
});

Entity Functions

entity.create(name, json_doc, [callback])

Create a new instance of the name entity from json_doc.

entity_json = { "id": 54, "value": "this is some data" }
akiban.entity.create('t1', entity_json, function(err, body) {
  if (!err) {
    console.log(body);
  }
});

entity.get(name, id, [callback])

Retrieve a single instance of the entity called name whose identifier is id.

akiban.entity.get('t1', 54, function(err, body) {
  if (!err) {
    console.log(body);
  }
});

entity.destroy(name, id, [callback])

Destroy a single instance of the entity called name whose identifier is id. Successful response has an empty body.

akiban.entity.destroy('t1', 54, function(err, headers) {
  if (!err) {
    console.log(headers);
  }
});

entity.replace(name, id, [callback])

Replace the entire instance of the entity called name whose identifier is id.

akiban.entity.replace('t1', 54, function(err, body) {
  if (!err) {
    console.log(body);
  }
});

SQL Functions

sql.execute(query, [callback])

Execute a single SQL query.

akiban.sql.execute('select * from  t1', function(err, body) {
  if (!err) {
    console.log(body);
  }
});

sql.explain(query, [callback])

Generate an execution plan for a single SQL query.

akiban.sql.explain('select * from  t1', function(err, body) {
  if (!err) {
    console.log(body);
  }
});

sql.multi(queries, [callback])

Execute multiple SQL statements within a single transaction. Individual statements can be free-form and must be separated by semicolons (;).

queries = 'select * from t1; select max(id) from t1;';
akiban.sql.multi(queries, function(err, body) {
  if (!err) {
    console.log(body);
  }
});

Full Text Functions

ft.search(entity_name, index_name, query, [callback])

Perform a full text search on the specified index.

akiban.ft.search('t1', 'ft_idx', 'value:dream', function(err, body) {
  if (!err) {
    console.log(body);
  }
});

ft.rebuild(entity_name, index_name, [callback])

Rebuild the given index.

akiban.ft.rebuild('t1', 'ft_idx', function(err, body) {
  if (!err) {
    console.log(body);
  }
});