@ClementRicateau
cRicateau
L'import a échoué. Merci de corriger les erreurs et de ré-essayer
L'import a réussi (2 lignes importées sur 200 000)
jdrouet/loopback-component-storage-postgres
var fork;
fork = require('child_process').fork;
Invoice.upload_fork = function(params) {
return fork(__dirname + "/../../server/scripts/import-script.coffee", params);
};
Invoice.beginTransaction(
{
isolationLevel: Post.Transaction.READ_COMMITTED
}, function(err, tx) {
// Now we have a transaction (tx)
});
{
"_meta": {
...
"mixins": [
...
"./mixins"
]
}
}
Model.import = function(file) {
var tx;
tx = {};
return Model.startTransaction(tx, file)
.then(function() {
return Model.importProcess(tx, file);
})
.then(function() {
return Model.exitAfterSuccess(tx);
})
.catch(function(err) {
return Model.exitAfterError(tx);
});
});
};
{
"name": "Invoice",
"base": "PersistedModel",
"mixins": {
"Upload": {},
},
{
"name": "Invoice",
"base": "PersistedModel",
"mixins": {
"Upload": {},
"CsvUpload": {
"requiredHeaders": [
"invoiceId",
"amount"
],
"validators": {
"invoiceId": {
"required": true,
"type": "string"
},
"amount": {
"required": true,
"type": "integer"
}
}
},
loopback-promisify
Loopback 3.0
cRicateau/loopback-csv-import