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

@kohanajs/mod-admin

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kohanajs/mod-admin - npm Package Compare versions

Comparing version 5.5.1 to 5.6.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [5.6.0](https://gitlab.com/kohana-js/modules/admin/compare/v5.5.1...v5.6.0) (2023-07-19)
### Features
* list duplicated, update and created records ([1cc5959](https://gitlab.com/kohana-js/modules/admin/commit/1cc59599c7de9439f6a4053ebd240d8f83907e72))
### [5.5.1](https://gitlab.com/kohana-js/modules/admin/compare/v5.5.0...v5.5.1) (2023-07-19)

@@ -7,0 +14,0 @@

26

classes/controller-mixin/Import.js

@@ -18,5 +18,10 @@ const { ControllerMixin } = require('@kohanajs/core-mvc');

static DUPLICATED_CSV_RECORDS = 'import_duplicated_csv_records';
static CREATED_CSV_RECORDS = 'import_created_csv_records';
static UPDATED_CSV_RECORDS = 'import_updated_csv_records';
static init(state) {
state.set(this.DUPLICATED_CSV_RECORDS, []);
state.set(this.CREATED_CSV_RECORDS, []);
state.set(this.UPDATED_CSV_RECORDS, []);
if(!state.get(this.UNIQUE_KEY))state.set(this.UNIQUE_KEY, 'email');

@@ -93,2 +98,6 @@ if(!state.get(this.HEADER_COLUMN_MAP))state.set(this.HEADER_COLUMN_MAP, new Map());

const duplicatedCSVRecords = state.get(this.DUPLICATED_CSV_RECORDS);
const createdCSVRecords = state.get(this.CREATED_CSV_RECORDS);
const updatedCSVRecords = state.get(this.UPDATED_CSV_RECORDS);
//create or update records

@@ -107,7 +116,7 @@ await Promise.all(

//update exist record
Object.assign(existRecord, result);
await existRecord.write();
await state.get(this.IMPORT_INSTANCE_HANDLER)(state, existRecord, result);
await this.writeRecord(state, existRecord, result);
updatedCSVRecords.push(Object.assign({}, result));
return;
}
duplicatedCSVRecords.push(Object.assign({},result));
return;

@@ -123,10 +132,15 @@ }

const newRecord = ORM.create(Model, options);
Object.assign(newRecord, result);
await newRecord.write();
await state.get(this.IMPORT_INSTANCE_HANDLER)(state, newRecord, result);
await this.writeRecord(state, newRecord, result);
createdCSVRecords.push(Object.assign({id: newRecord.id}, result));
})
);
}
static async writeRecord(state, instance, csvRecord){
Object.assign(instance, csvRecord);
await instance.write();
await state.get(this.IMPORT_INSTANCE_HANDLER)(state, instance, csvRecord);
}
}
module.exports = ControllerMixinImport;
{
"name": "@kohanajs/mod-admin",
"version": "5.5.1",
"version": "5.6.0",
"description": "Admin templates for KohanaJS ORM",

@@ -5,0 +5,0 @@ "main": "index.js",

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