# js-data-datastore

> Datastore adapter for js-data

Latest version **2.1.2** (published 2021-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-data-datastore
pnpm add js-data-datastore
yarn add js-data-datastore
bun add js-data-datastore
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2021-01-20 |
| First published | 2017-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 174.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | finwo, dariuszdusza |

## Links

- npm: https://www.npmjs.com/package/js-data-datastore
- Repository: https://github.com/trackthis/js-data-datastore
- Homepage: https://github.com/trackthis/js-data-datastore#readme
- Issues: https://github.com/trackthis/js-data-datastore/issues
- npm.io page: https://npm.io/package/js-data-datastore

## Dependencies (4)

- [co](https://npm.io/package/co.md) ^4.6.0
- [js-data](https://npm.io/package/js-data.md) ^3.0.1
- [js-data-adapter](https://npm.io/package/js-data-adapter.md) ^1.0.1
- [@google-cloud/datastore](https://npm.io/package/@google-cloud/datastore.md) ^6.1.0

## Recent versions

- 2.1.2 (latest) — 2021-01-20
- 2.1.1 — 2021-01-20
- 2.1.0 — 2018-06-13
- 2.0.0 — 2018-04-12
- 1.1.2 — 2018-04-12
- 1.1.1 — 2018-03-19
- 1.1.0 — 2018-02-12
- 1.0.9 — 2018-02-08
- 1.0.8 — 2018-02-01
- 1.0.6 — 2017-12-20
- 1.0.5 — 2017-12-20
- 1.0.3 — 2017-12-20
- 1.0.2 — 2017-12-20
- 1.0.4 — 2017-12-20
- 1.0.1 — 2017-11-22
- … 1 more at https://npm.io/package/js-data-datastore/versions

## README

<img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="96" height="96" />

[![npm](https://img.shields.io/npm/v/js-data-datastore.svg?style=flat-square)](https://npmjs.com/package/js-data-datastore/)
[![Scrutinizer Build](https://img.shields.io/scrutinizer/build/g/trackthis/js-data-datastore.svg?style=flat-square)](https://scrutinizer-ci.com/g/trackthis/js-data-datastore/)
[![Scrutinizer](https://img.shields.io/scrutinizer/g/trackthis/js-data-datastore.svg?style=flat-square)](https://scrutinizer-ci.com/g/trackthis/js-data-datastore/)
[![Scrutinizer Coverage](https://img.shields.io/scrutinizer/coverage/g/trackthis/js-data-datastore.svg?style=flat-square)](https://scrutinizer-ci.com/g/trackthis/js-data-datastore/)
[![npm](https://img.shields.io/npm/l/js-data-datastore.svg?style=flat-square)](https://npmjs.com/package/js-data-datastore/)

# js-data-datastore

A DataStore adapter for the JSData Node.js ORM.
Updated version of js-data-cloud-datastore.
Credits to JDobry.

### Installation

    npm install --save js-data js-data-datastore 

### Usage

```js
var jsDataDataStore = require('js-data-datastore');

/*
 *  Create an instance of DataStoreAdapter
 */
var adapter = new jsDataDataStore.DataStoreAdapter({config: {
    projectId: 'projectId',
    namespace: 'namespace',
    keyFilename: 'path_to_keyFilename'
}});

/*
 *  Register the adapter instance
 */
store.registerAdapter('datastore', adapter, { default: true });
```

### JSData Tutorial

Start with the [JSData].

### License

[The MIT License (MIT)]

### Example

```js
var jsData          = require('js-data');
var jsDataDataStore = require('js-data-datastore');

/*
 *  Optional
 */
jsData.utils.Promise = require('bluebird');

var config = {
    projectId: 'projectId',
    namespace: 'namespace',
    keyFilename: path_to_keyFilename
};

var adapter = new jsDataDataStore.DataStoreAdapter({config: {
    projectId: 'projectId',
    namespace: 'namespace',
    keyFilename: path_to_keyFilename
}});

var container = new jsData.Container({ mapperDefaults: { } });

container.registerAdapter('datastore', adapter, { 'default': true });

container.defineMapper('users');

container
    .count('users')
    .then(function (data) {
        res.send(JSON.stringify(data));
    })
    .catch(function (error) {
        res.send('ERROR<br>' + JSON.stringify(error));
    });

container
    .create('users',{name: 'name', password: 'password'})
    .then(function (data) {
        res.send(JSON.stringify(data));
    })
    .catch(function (error) {
        res.send('ERROR<br>' + JSON.stringify(error));
    });


container
    .findAll('users',{where: { password: { '==': 'password'} } })
    .then(function (data) {
        res.send(JSON.stringify(data));
    })
    .catch(function (error) {
        res.send('ERROR<br>' + JSON.stringify(error));
    });
```

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