0.1.1 • Published 9 years ago

rethinkdb-fixtures v0.1.1

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

rethinkdb-fixtures

Easily load fixtures into Rethinkdb. Useful for testing.

Insert

const options = {
    db: 'test',
    clear: true // This will make sure tables are cleared before inserting.
};
const rdbFix = require('rethinkdb-fixtures')(options);
const Insert = rdbFix.Insert;

const fixture = {
        items: [
            {
                name: 'Bike'
            },
            {
                name: 'Wrench'
            }
        ],
        people: [
            {
                name: 'Wild Man Fischer'
            },
            {
                name: 'Charles Ponzi'
            }
        ]
    }
};

Insert(fixture).then( (createdObjects) => {

    console.log(createdObjects.items, createdObjects.people);
}, console.error);

Delete

const Delete = rdbFix.Delete;
Delete(['items', 'people']).then( (result) => {

    console.log(result); // standard rethinkdb change objects
},console.error);

Closing connection

rdbFix.base.close().then( function () {

   console.log(`I've closed the connection`);
});

To test:

make sure you have an instance of rethinkdb running somewhere

npm test

Command line usage

To insert:

export RETHINKDB=test
export FIXTURE=./fixtures.json
node ./bin/insert.js

To delete tables

export RETHINKDB=test
export TABLES='table1,table2,table3'
node ./bin/delete.js
0.1.1

9 years ago

0.1.0

9 years ago

0.0.9

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago