Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

barreller

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barreller

Ever wanted to populate a postgres db with tons of fake data? Well, barreller does that.

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Barreller

Ever wanted to populate a postgres db with tons of fake data? Well, barreller does that.

Barreller prescribes a way to define your tables, column values, and relationships, and then import infinite data into postgres.

Inspiration came from wanting to create lots of fake data, but being constained by maintaining the relationships between that data. Especially when sometimes those relationships depend on server-side generated primary keys.

As of this writing - very much a Work In Progress... But it does work!

Example usage:

// define the type for the table
type Food = {
  foodId: string;
  calories: number;
}

// define columns
const foodColumnId: ColumnDefinition<FoodTable, 'foodId'> = {
  // name equals the table's column name
  name: 'food_id',

  // prop is optional and will be the key used when generating the data locally
  prop: 'foodId',

  // value can be a constant (i.e. a string, number, void, date, etc.)
  // or it can be a function and is invoked each time a row is generated
  value() { return faker.random.word(); }
};

const foodColumnCalories: ColumnDefinition<FoodTable, 'calories'> = {
  name: 'calories',
  value: 100
};

const foodColumns: ColumnDefinitions<FoodTable> = [
  foodColumnId,
  foodColumnCalories
];

const barrel = new Barrel({ pgConnectionObject });

// 'food' is the table name and it is also the string used to generate rows
barrel.addTable('food', foodColumns);

// this queues up the data to be inserted, but does NOT insert it
barrel.generateRow('food');

// inserts any queued up data. This is an async function.
barrel.insert();

TODO

  • finish the abstract Barrel class
    • connect method
    • disconnect method
  • Convert current Barrel class to PostgresBarrel as subclass of Barrel
  • Move driver implementation into drivers/pg.ts
  • support generatedKey(tableName, columnName) for server generated private keys.
  • consider batch.insertFunction as a deferred promise object

FAQs

Package last updated on 16 Oct 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc