Socket
Socket
Sign inDemoInstall

@yadah/objection-copy

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @yadah/objection-copy

Objection.js mixin to bulk import data


Version published
Maintainers
1
Created

Readme

Source

Objection Copy mixin

A mixin for Objection.js which adds a copyFromCsv() static function to Model classes. It allows streaming CSV data to objection model tables.

Uses SQL COPY FROM to perform data import.

Usage

import { mixin, Model } from "objection";
import CopyMixin from "@yadah/objection-copy";

class MyModel extends mixin(Model, [CopyMixin]) {
  static tableName = "mytable";
}

const fromStream = Readble.from(`"foo 1","bar 1"\n"foo 2","bar 2"`);
const columns = ["field1", "field2"];
const rowCount = await MyModel.copyFromCsv(fromStream, columns); // 2

Keywords

FAQs

Last updated on 08 Apr 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc