FileBasedStoreLoader

@unitybase/base/FileBasedStoreLoader~ FileBasedStoreLoader

new FileBasedStoreLoader(config)

Arguments:
  1. config (Object)
    Properties
    1. entity (TubEntity|UBEntity)
    2. foldersConfig (Array.<{path: string}>)  Array of folder configuration to scan for files. Necessary param is path - path to folder. You can also pass additional information for use in onBeforeRowAdd and onNewFolder callbacks. Currently processed root folder accessible from FileBasedStoreLoader.processingRootFolder
    3. zipToArray (Boolean)  Transform result from array of object to array-of-array representation. Default true
    4. uniqueID (Boolean)  Result data must contain ID attribute and values must be unique. Default true.
    5. [fileMask] (RegExp)  Regular expression to filter folder files. Each fileName (without path) will be tested by this regExp
    6. [attributeRegExpString] (String)  String representation of regular expression to found attribute and it value in input content. Default is '^\/\/@(\w+)\s"(.*?)"' what mean find all string like: //@attribute "value" You can pass empty string to disable attribute parsing by regExp and do it manually in onBeforeRowAdd handler.
    7. [onBeforeRowAdd] (function)  Callback called for each row BEFORE it added to store. In case it return false row not added. Called with args (this: FileBasedStoreLoader, fullFilePath: string, fileContent: string, oneRow: Object);
    8. [onNewFolder] (function)  Callback called for each new folder in case of recursive folder. In case callback return false or not defined - folder not processed. Called with args (this: FileBasedStoreLoader, fullFolderPath: string, recursionLevel: integer);
Example
const FileBasedStoreLoader = require('@unitybase/base')FileBasedStoreLoader
    let loader = new FileBasedStoreLoader({
      entity: me.entity,
      foldersConfig: folders,
      fileMask: /-fm\.def$/,
      onBeforeRowAdd: postProcessing
    });
    let resultDataCache = loader.load()

Members

config: Object

Configuration

attributes: Array.<Object> readonly

Entity attributes array

haveModifyDate: Boolean readonly

Is mStore.simpleAudit enabled for current entity (exist mi_modifyDate attribute)

haveCreateDate: Boolean readonly

Is mStore.simpleAudit enabled for current entity (exist mi_createDate attribute)

processingRootFolder: * readonly

Currently processed root folder

resultCollection: Array.<Object> protected

Array of Object representing dirty result

Methods

load()TubCachedData

Perform actual loading.