# trapperkeeper

> a lightweight, storage agnostic data abstraction based on Resourceful

Latest version **0.1.0** (published 2012-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install trapperkeeper
pnpm add trapperkeeper
yarn add trapperkeeper
bun add trapperkeeper
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2012-11-29 |
| First published | 2012-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6.x |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Cody Stoltman |
| Maintainers | particlebanana |
| Keywords | database, ODM, resourceful |

## Links

- npm: https://www.npmjs.com/package/trapperkeeper
- Repository: https://github.com/School-Yard/TrapperKeeper
- npm.io page: https://npm.io/package/trapperkeeper

## Dependencies (5)

- [i](https://npm.io/package/i.md) 0.3.x
- [mysql](https://npm.io/package/mysql.md) 2.0.x
- [redis](https://npm.io/package/redis.md) 0.8.x
- [hiredis](https://npm.io/package/hiredis.md) 0.1.x
- [mongodb](https://npm.io/package/mongodb.md) 1.1.x

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2012-11-29
- 0.0.5 — 2012-10-19
- 0.0.4 — 2012-08-16
- 0.0.3 — 2012-08-16
- 0.0.2 — 2012-08-14
- 0.0.1 — 2012-08-03

## README

Trapper Keeper
==============

A super lightweight and storage agnostic data abstraction layer.

[![Build Status](https://secure.travis-ci.org/School-Yard/TrapperKeeper.png?branch=master)](http://travis-ci.org/School-Yard/TrapperKeeper)

When you don't want to use Resourceful throw it in Trapper Keeper. A lot of the underlying code and engine structure
is based on Resouceful but all the hooks, events and relationships are stripped out.

## Example

``` js
var trapper_keeper = require('trapperkeeper');

// Create a connection to a data store
var db = trapper_keeper.connect('mongodb', 'mongodb://127.0.0.1', 27017, { database: 'awesome' });

// Create a namespaced resource
// Namespace will correspond with data store key, collection, table, etc.
var resource = db.resource('namespace');

db.connection.on('ready', function() {
  resource.get(id, callback);
  resource.create(attrs, callback);
});
```

### Engines

Trapper Keeper currently has engines for:

  - Memory
  - MongoDB
  - Redis
  - MySQL

### Caching

Using the cache feature is optional, current engines that support this feature:

  - Memory
  - Redis

An example of a resource with caching:
```
// Define a resource with cache functionality
var resource = connection.resource('user').cache('memory');
```

## Function Signatures

``` js
resource.get(id, callback);

resource.create(attrs, callback);

resource.save(id, attrs, callback);

resource.destroy(id, callback);

resource.update(id, attrs, callback);

resouce.find(conditions, callback);

resouce.all(callback);
```

## Installation

### Installing trapper-keeper
``` bash
  $ [sudo] npm install trapperkeeper
```

## Tests
All tests are written with [mocha][0] and should be run with [npm][1]:

``` bash
  $ npm test
```

[0]: http://visionmedia.github.com/mocha/
[1]: http://npmjs.org

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