1.0.0 • Published 4 years ago

ds-extender v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

Dreamtsoft node extender

Running extender

Initial run (if you not paired)

Pair to site

Once the pairing process has started, go into your site to see status

  • System bundle
    • General
      • Data services

Normal starting after paired


Making extender do stuff

In order to make the extender execute commands, you need to setup 4 things

  • Make sure extender is paired and online
  • Create a Script data store that defines the script to the system
  • Put the phyiscal script in the work/ directory
  • Related the Script data store to the extender dataservice record

Script data store

Script data store tells the system what the script name is (and location), what schema (slots) is expected to exist on the rows

You can access script data stores by going to the Data store bucket

  • Bundle configuration (gears)
    • Bucket management

      • Data stores

Put script in work directory

Create your js script in your extenders work directory, for example:

/code/ds-extender/work/MyScript.js

Relating data store to data service record

Can be done data store screen or the data service screen

Navigate to your data service

  • System bundle
    • General
      • Data services

And click on your extender. On the lower part of the screen you'll see the "Installed scripts" section. You can use the relationship editor to relate the Script data store to your dataservice record.


Example extender script

MyScript.js

module.exports = class MyMapper {
    start() {
        // this function will get called on startup of the extender
        // can be used to setup background work
        setInterval(this.check.bind(this), 30000);
    }

    check() {
    }

    // FRecord.insert
    insert() {
        return [];
    }

    // FRecord.update
    update() {
        return [];
    }

    // FRecord.del
    del() {
        return [];
    }

    // FRecord.search
    search(search) {
        return [ { "my_field": "aaa" } ];
    }

    // FRecord.api
    api(apiName, data) {
        if (api == "my_name") {
            return [
                    { field: "a", valid: true },
                    { field: "b", valid: 0 }
            ];
        }

        return [];
    }
}
1.0.0

4 years ago