Giter Site home page Giter Site logo

Comments (2)

faisalsami avatar faisalsami commented on May 31, 2024 1

from nodem.

dlwicksell avatar dlwicksell commented on May 31, 2024

Yes, there are a couple ways to handle this. First, if the database connection hasn't been opened, then the Nodem APIs will return with an exception, which you could catch in a try/catch statement, and then open the connection to the database before using the APIs, e.g.

> const nodem = require('nodem').Ydb();
undefined
> nodem.get('^global');
Uncaught Error: YottaDB connection is not open
> try {
... nodem.get('^global');
... } catch (err) {
... nodem.open();
... nodem.get('^global');
... }
1000

Second, the version API only reports the version of the underlying YottaDB or GT.M system, when the database connection has been opened, so you could search for the substring 'YottaDB Version' (or 'GT.M Version' when using GT.M), in the output of the version API, to determine if there is a current database connection, e.g.

> const nodem = require('nodem').Ydb();
undefined
> nodem.version();
'Node.js Adaptor for YottaDB: Version: 0.20.0 (ABI=93) [FWS]'
> nodem.version().includes('YottaDB Version');
false
> nodem.open();
{ ok: true, pid: 86593, tid: 86593 }
> nodem.version();
'Node.js Adaptor for YottaDB: Version: 0.20.0 (ABI=93) [FWS]; YottaDB Version: 1.32'
> nodem.version().includes('YottaDB Version');
true

I hope that helps! I'm going to close this issue, as I believe I have addressed it sufficiently. Thank you.

from nodem.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.