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

@shagital/adonisjs-seeder-generator

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

@shagital/adonisjs-seeder-generator - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "@shagital/adonisjs-seeder-generator",
"version": "1.0.2",
"version": "1.0.3",
"description": "An AdonisJS (nodejs) package to generate seeder files from existing DB table data",

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

@@ -65,2 +65,57 @@ # AdonisJS Seeder Generator

## Example Seeder file
```js
'use strict';
/*
|--------------------------------------------------------------------------
| CitiesSeeder
|--------------------------------------------------------------------------
|
| Make use of the Factory instance to seed database with dummy data or
| make use of Lucid models directly.
|
*/
const Database = use('Database');
class CitiesSeeder {
async run () {
await Database.connection('mysql').table('cities').truncate();
let data = [
{
"id": 219,
"name": "Kuçovë",
"country_id": 3,
"state_id": 629,
"country_code": "AL",
"state_code": "BR",
"latitude": 40.80028,
"longitude": 19.91667
},
{
"id": 280,
"name": "Çorovodë",
"country_id": 3,
"state_id": 629,
"country_code": "AL",
"state_code": "BR",
"latitude": 40.50417,
"longitude": 20.22722
}
...
];
var i, j, temparray, chunk = 1000;
for (i = 0,j = data.length; i < j; i += chunk) {
temparray = data.slice(i, i+chunk);
await Database.connection('mysql').table('cities').insert(temparray);
}
}
}
module.exports = CitiesSeeder;
```
## Changelog

@@ -67,0 +122,0 @@

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