Search code examples
orientdborientjs

Batch script in orientjs does not work


I am trying to execute a batch script with orientjs as suggested in the orientjs docs but I get the following error:

Unhandled rejection OrientDB.RequestError: Cannot find a command executor for the command request: sql.begin;let $susers = select from susers;return $susers
    Storage URL="plocal:/Users/amyth/projects/orient/orientdb-community-2.2.0/databases/konnect"
    at Operation.parseError (/Users/amyth/projects/konnect/node_modules/orientjs/lib/transport/binary/protocol33/operation.js:865:13)
    at Operation.consume (/Users/amyth/projects/konnect/node_modules/orientjs/lib/transport/binary/protocol33/operation.js:455:35)
    at Connection.process (/Users/amyth/projects/konnect/node_modules/orientjs/lib/transport/binary/connection.js:399:17)
    at Connection.handleSocketData (/Users/amyth/projects/konnect/node_modules/orientjs/lib/transport/binary/connection.js:290:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20

For a script as simple as:

begin;let $susers = select from susers;return $susers

Am I doing something wrong ? or is this a bug ?


Solution

  • Try

    db.query("begin;let $susers = select from susers;return $susers",{class: 's'}).then(function(res){
     console.log(res)
    })
    

    Seems that the docs has been changed recently leaving out the {class: 's'}