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

gcloud-datastore

v0.0.12

Published

A wrapper for accessing Google's Datastore through Node applications

Downloads

17

Readme

gcloud-datastore {

Build Status Code Climate

This package is installable by using npm install --save gcloud-datastore.

Using the Query Manager

The idea behind the query manager is a first-in-first-out stack. The query manager is essentialy a stack that holds query until they are executed. Once executed, all of the results are return in an array.

Quick Example

Here is how the query manager works, at a very basic level.

Sample datastore:

Kind: Animal

| id/name | species | name | | -------------|:-------------:| -----:| | 871398717813 | lion | Simba | | 234885878798 | tiger | Tony | | 873485798374 | bear | Baloo |

Code
var datastore = require('gcloud-datastore');

// Synchronous callback
datatore.addQuery(query, function(error, queryStackLength) {
    if(error)
        throw error;
    else
        console.log('There is now ' + queryStackLength + ' query in the stack.');
});

// Asynchronous callback
datastore.runAllQueries(function(error, result) {
    if(error)
        throw error;
    else
        console.log(result);
});

Documentation

datastore

datastore

addAllQueries(queries)

A function used to add an array of queries to the stack.

Parameters

  • queries - An array of query objects to be added to the stack.

Returns The new length of the stack after the queries have been inserted.

Example

var animalQuery = datastore.createQuery('Animal');
var movieQuery = datastore.createQuery('Movie');
var queries = [animalQuery, movieQuery];

var stackLength = datastore.addAllQueries(queries);

addQuery(query)

A function used to add one query to the stack.

Parameters

  • query - A query object to be added to the stack.

Returns The new length of the stack after the query has been inserted.

Example

var animalQuery = datastore.createQuery('Animal');

var stackLength = datastore.addQuery(animalQuery);

createQuery([namespace], kind)

A function used to create a new Query object.

Note This acts exactly like the createQuery method supplied by the gcloud-node API.

Parameters

  • namespace - An optional namespace to use for the query.
  • kind - The kind to use for the query.

Returns A new Query object.

Example

var animalQuery = datastore.createQuery('Animal');

getAllQueries()

A function used to get an array containing all of the queries currently in the stack.

Returns An array containing all of the queries currently stored in the stack.

Example

var queries = datastore.getAllQueries();

getNextQuery();

A function used to get the next query to be run in the stack, based on the FIFO model.

Returns The next query to be run in the stack.

Example

var query = datastore.getNextQuery();

getStackLength()

A function used to get the length of the stack.

Returns The length of the stack.

Example

var stackLength = datastore.getStackLength();

removeAllQueries()

A function used to remove all of the queries from the stack. This function acts in a similar manner to the getAllQueries function, but empties the stack as well as retrieving all of the queries currently in the stack.

Returns An array containing all of the queries that were removed from the stack.

Example

var queries = datastore.removeAllQueries();

removeNextQuery()

A function used to the next query from the stack, based on the FIFO model. This function acts in a similar manner to the getNextQuery function, but removes the next query from the stack as well as retrieving it.

Returns The query object that was removed from the stack.

Example

var query = datastore.removeNextQuery();

runAllQueries(callback)

A function used to execute all of the queries from the stack against the Datastore.

Parameters

  • callback(error, result) - A callback that returns any errors that occured while trying to execute the queries stored in the stack or null, and an array individual arrays of results corresponding to each query (or null if there were errors).

Example

datastore.runAllQueries(function(error, result) {
    if(!error){
        // do something
    }
});

runNextQuery(callback)

A function used to execute the next query from the stack against the Datastore.

Parameters

  • callback(error, result) - A callback that returns any errors that occured while trying to execute the queries stored in the stack or null,

Example

datastore.runNextQuery(function(error, result) {
    if(!error){
        // do something
    }
});

runQuery(query, callback)

A function used to execute the inputted query against the Datastore.

Parameters

  • query - A query object to execute.
  • callback(error, result) - A callback that returns any errors that occured while trying to execute the queries stored in the stack or null,

Example

var query = datastore.createQuery('Animal');

datastore.runQuery(query, function(error, result) {
    if(!error){
        // do something
    }
});

License

MIT

Fork away!

}