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

odapi

v0.0.1

Published

JS Api for working with an OData backend

Downloads

1

Readme

ODApi

Build with gulp. Install with: npm install gulp gulp-concat gulp-rename gulp-uglify.

Run the unit tests

Open test.html in a browser and show the developer console.

You need a odataserver2 backend. Make sure it is running if you have it installed locally.

Test the mysql functions with: testOdata.createAccounts() followed by testOdata.testMysql(). You will get a 406 if the account already exists. The function testOdata.cleanup() can be used to make sure all old test data is deleted. The accounts will not be deleted though.

Test the leveldb functions with: testOdata.createAccounts() followed by testOdata.testLevelDb().

Using the back end API

Setup these helpers: var log = console.log.bind(console); var error = console.log.bind(console, 'ERROR')

Show the help page: Odata.help(Odata.DEV_URL).then(function(res){log(res.data)}, function(res){log(res.data)})

Let's gather the credentials in an object so we don't have to type them: var options = {url: Odata.DEV_URL, email: '[email protected]'}

Create an account and save the account id (you'll get a 406 id the account already exists, just continue to the next step): Odata.createAccount(options).then(function(res){log(options.accountId=res.data[1].accountId)}, function(res){log(options.accountId=res.data[1].accountId)})

Take a note of the account id that was returned. Now generate a password: Odata.resetPassword(options).then(function(res){log(options.password=res.data[0].password)}, error)

Note down the password (this feature is only enabled in dev and test environments).

Create one more account.

Let's gather the credentials in an object so we don't have to type them: var options2 = {url: Odata.DEV_URL, email: '[email protected]'}

Odata.createAccount(options2).then(function(res){log(options2.accountId=res.data[1].accountId)}, function(res){log(options2.accountId=res.data[1].accountId)})

Take a note of the account id that was returned. Now generate a password: Odata.resetPassword(options2).then(function(res){log(options2.password=res.data[0].password)}, error)

Working with tables

Now create a Odata object with account just created and use it:

var od = new Odata(options);
od.createTable('mytable', ["col1 int","col2 varchar(255)"]).then(log);
od.accountInfo().then(log);

Grant access for Joe's new table to Gina and insert some data:

od.grant('mytable', '9590c009ef00').then(console.log.bind(console));

od.insert('3ea8f06baf64', 'mytable', {"col1":11,"col2":"11"}).then(log);
od.insert('3ea8f06baf64', 'mytable', {"col1":1000,"col2":"1010"}).then(log);

od.get('3ea8f06baf64', 'mytable').then(log);
od.get('3ea8f06baf64', 'mytable', 'col1').then(log);
od.get('3ea8f06baf64', 'mytable', null, 'col1 eq 11').then(log);

Delete a row:

od.delete('3ea8f06baf64', 'mytable', 'col1 eq 11').then(log);
od.get('3ea8f06baf64', 'mytable').then(log);

Update a row:

od.update('3ea8f06baf64', 'mytable', {"col1":1000,"col2":"1011"}, 'col1 eq 1000').then(log);
od.get('3ea8f06baf64', 'mytable').then(log);

Drop a table:

od.drop('mytable').then(log);

Cleanup:

od.deleteAccount('3ea8f06baf64').then(log);

Working with buckets

Create a bucket (key/value store):

var od = new Odata(Odata.DEV_URL, '3ea8f06baf64', 'o1Z4zxyPSUQO');
od.createBucket('b_mybucket').then(log);
od.store('3ea8f06baf64', 'b_mybucket', 'Some data to store in a bucket').then(log);
od.fetch('3ea8f06baf64', 'b_mybucket').then(log);