@nest-toolbox/typeorm-upsert
TypeScript icon, indicating that this package has built-in type declarations

1.5.1 • Public • Published

typeorm-upsert

Installation

npm i @nest-toolbox/typeorm-upsert

Usage

const dataTypeRepository; // typeorm repository
const bigArrayWithData = []; // this array contains existing data and new data
const conflictKey = 'unq index/key'; // you can use this function in the case you want to track collision on other key then id;

const options = { // all the options are optional
    keyNamingTransform: (k)=>k, // you can pass a callback function to change the keys in case that your having a naming convention like snake_case
    doNotUpsert: [], // array of keys that you want to ignore durning the upsert maybe a status field or something
    chunk: 1000, // by default the function chunks the array in 1000 inserts you can increase or decrease this option
};

const updated = await TypeOrmUpsert(dataTypeRepository, bigArrayWithData, conflictKey, {
    doNotUpsert: ['name'],
});

Readme

Keywords

Package Sidebar

Install

npm i @nest-toolbox/typeorm-upsert

Weekly Downloads

27

Version

1.5.1

License

MIT

Unpacked Size

94.3 kB

Total Files

10

Last publish

Collaborators

  • lupu60