Answers for "file reader in loopback 4"

0

file reader in loopback 4

// MyModel.js
import fs = require('fs');
import xml = require('xml')
import csv = require('csv')

export function import(info, callback) {

    // Get the current database connection.
    var ds = this.dataSource.connector;

    // ***********************************************
    // ** READ FILES AND WRITE TO THE DATABASE HERE **
    // ***********************************************
    // --->
    // ***********************************************

    // Return results and/or error information.
    return callback(null, data)
}

export function remoteMethod(model: any) {
    model.remoteMethod(
        'import',
        {
            http: { verb: 'get' },
            accepts: {arg: 'info', type: 'data' },
            returns: [
                { arg: 'info', type: 'data' },
                { arg: 'data', type: 'data' }
            ]
        }
    )
    return model;
}
Posted by: Guest on March-30-2021

Browse Popular Code Answers by Language