# gcloud-keystore

> Use gcloud's Datastore as a key-value store.

Latest version **1.2.0** (published 2015-06-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gcloud-keystore
pnpm add gcloud-keystore
yarn add gcloud-keystore
bun add gcloud-keystore
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2015-06-28 |
| First published | 2014-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Author | Stephen Sawchuk |
| Maintainers | stephenplusplus |
| Keywords | gcloud, google, cloud, datastore, keyvalue |

## Links

- npm: https://www.npmjs.com/package/gcloud-keystore
- Repository: https://github.com/stephenplusplus/gcloud-keystore
- Issues: https://github.com/stephenplusplus/gcloud-keystore/issues
- npm.io page: https://npm.io/package/gcloud-keystore

## Recent versions

- 1.2.0 (latest) — 2015-06-28
- 1.1.0 — 2014-10-16
- 1.0.1 — 2014-10-14

## README

# gcloud-keystore
> Use a [gcloud-node](https://github.com/GoogleCloudPlatform/gcloud-node) dataset as a Key/Value store.


## Install
```sh
$ npm install --save gcloud-keystore
```


## Example
```js
var keystore = require('gcloud-keystore');
var gcloud = require('gcloud')(/*...*/);
var dataset = gcloud.datastore.dataset();

var keystore = keystore(dataset);

// Set an item.
keystore.set('todos', ['eat', 'sleep', 'repeat'], function(err, key) {});

// Get an item.
keystore.get('todos', function(err, todos) {
  // todos:
  //   ['eat', 'sleep', 'repeat']
});

// Delete an item.
keystore.delete('todos', function(err) {});
```


## How
[Google Cloud Datastore](https://cloud.google.com/datastore) is a managed, NoSQL, schemaless database for storing non-relational data. Datastore [entities](https://cloud.google.com/datastore/docs/concepts/entities) are complex objects. However, we can wrap this complexity to mimic a simple key/value store by storing a numeric or string "key" as the id of an entity.

The example below shows the complexity that is hidden with `gcloud-keystore`.

#### With `gcloud-node`:
```js
var key = dataset.key(['KeyValue', 'key']);

dataset.save({
  key: key,
  value: 'value'
}, function() {});

dataset.get(key, function() {});

dataset.delete(key, function() {});
```

#### With `gcloud-node` + `gcloud-keystore`:
```js
var keystore = require('gcloud-keystore')(dataset);

keystore.set('key', 'value', function() {});

keystore.get('key', function() {});

keystore.delete('key', function() {});
```


## API

### keystore(dataset)

#### dataset

A gcloud-node Datastore [Dataset](http://googlecloudplatform.github.io/gcloud-node/#/docs/master/datastore/dataset) instance.

### keystore#delete(key, callback)

#### key
Type: `String|Number`

#### callback
Type: `Function`
Executed with the same signature as [Dataset#delete](http://googlecloudplatform.github.io/gcloud-node/#/docs/master/datastore/dataset?method=delete).

### keystore#get(key, callback)

#### key
Type: `String|Number`

#### callback
Type: `Function`
Executed with (`err`, `value`)

### keystore#set(key, value, callback)

#### key
Type: `String|Number`

#### value
Type: `*`

#### callback
Type: `Function`
Executed with the same signature as [Dataset#save](http://googlecloudplatform.github.io/gcloud-node/#/docs/master/datastore/dataset?method=save).


## Credit

Concept originally created by [Patrick Costello](https://github.com/pcostell): https://github.com/GoogleCloudPlatform/gcloud-node/issues/256#issuecomment-58962323.


## License

MIT © Stephen Sawchuk

---
_Source: https://npm.io/package/gcloud-keystore · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
