New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

google-cloud-datastore-node

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-cloud-datastore-node

NodeJS library to simplify working with Google Cloud DataStore

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

google-cloud-datastore-node

NodeJS library to simplify working with Google Cloud DataStore

Based on a code by Google https://github.com/GoogleCloudPlatform/nodejs-getting-started

The difference is that this library uses Promises instead of callbacks which leads to a better code organization and can be used as well with async/await.

Installation

yarn add google-cloud-datastore-node

Usage

Setting up project id

const { setup, createDao } = require('google-cloud-datastore-node');

setup({
    projectId: 'my-awesome-project'
});

Creating an entity

const { setup, createDao } = require('google-cloud-datastore-node');

const testDao = createDao('Test');

testDao.create({
    firstname: 'John',
    lastname: 'Tester'
}).then(() => {
    console.log('Entry has been created!');
}).catch(err => console.error(err));

Reading an entity

const { setup, createDao } = require('google-cloud-datastore-node');

const testDao = createDao('Test');

testDao.read('<ID>').then((data) => {
    console.log(data);
}).catch(err => console.error(err));

Updating an entity

const { setup, createDao } = require('google-cloud-datastore-node');

const testDao = createDao('Test');

testDao.update('<ID>', {
    firstname: 'John',
    lastname: 'Tester'
}).then(() => {
    console.log('Entry has been updated!');
}).catch(err => console.error(err));

Deleting an entity

const { setup, createDao } = require('google-cloud-datastore-node');

const testDao = createDao('Test');

testDao.delete('<ID>').then(() => {
    console.log('Entry has been deleted!');
});

Listing entities

const { setup, createDao } = require('google-cloud-datastore-node');

const testDao = createDao('Test');

/* parameters are `limit`, `order`, `token` */
testDao.list(10, 'test').then(({ data, hasMore }) => {
    /* `hasMore` can be re-used as a `token` param in case of pagination implementation */
    console.log(data);
});

Listing entities with filters applied

const { setup, createDao } = require('google-cloud-datastore-node');

const testDao = createDao('Test');

/* parameters are `filters`, `limit`, `order`, `token` */
testDao.listBy([
    ['location', 'CA']
], 10, 'test').then(({ data, hasMore }) => {
    /* `hasMore` can be re-used as a `token` param in case of pagination implementation */
    console.log(data);
});

Additional information

License

MIT

Keywords

google

FAQs

Package last updated on 04 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts