obj/src/persistence/JsonFilePersister.js
/**
     * Loads data items from external JSON file.
     *
     * @param correlationId    (optional) transaction id to trace execution through call chain.
     * @returns                a list with loaded data items.
     */
Loads data items from external JSON file.
@param correlationId    (optional) transaction id to trace execution through call chain.
@returns                a list with loaded data items.
Loads data items from external JSON file . @param correlationId ( optional ) transaction id to trace execution through call chain . @returns a list with loaded data items .
load(correlationId) {
        return __awaiter(this, void 0, void 0, function* () {
            if (this._path == null) {
                throw new pip_services3_commons_nodex_1.ConfigException(correlationId, "NO_PATH", "Data file path is not set");
            }
            if (!fs.existsSync(this._path)) {
                return [];
            }
            try {
                let json = fs.readFileSync(this._path, "utf8");
                let list = pip_services3_commons_nodex_3.JsonConverter.toNullableMap(json);
                let arr = pip_services3_commons_nodex_4.ArrayConverter.listToArray(list);
                return arr;
            }
            catch (ex) {
                throw new pip_services3_commons_nodex_2.FileException(correlationId, "READ_FAILED", "Failed to read data file: " + this._path).withCause(ex);
            }
        });
    }
load ( correlationId ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { if ( this . _path == null ) { throw new pip_services3_commons_nodex_1 . ConfigException ( correlationId , "NO_PATH" , "Data file path is not set" ) ; } if ( ! fs . existsSync ( this . _path ) ) { return [ ] ; } try { let json = fs . readFileSync ( this . _path , "utf8" ) ; let list = pip_services3_commons_nodex_3 . JsonConverter . toNullableMap ( json ) ; let arr = pip_services3_commons_nodex_4 . ArrayConverter . listToArray ( list ) ; return arr ; } catch ( ex ) { throw new pip_services3_commons_nodex_2 . FileException ( correlationId , "READ_FAILED" , "Failed to read data file: " + this . _path ) . withCause ( ex ) ; } } ) ; }
Loads data items from external JSON file.
Loads data items from external JSON file .