node-red / node-red/node-red-nodes

notify when db is ready

Open
#90 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
13h 57m
Merged PRs (30d)
3

Description

Hi

I have tried using your level db from another module.

I can use this, this.levelConfig = RED.nodes.getNode(n.level);

Then access this.levelConfig.db.get/put

However, there is a latency issue in that I am not aware when the db has been initialised.

Suggest emitting even here:

   lvldb(this.dbname, function(err, db) {
        if (err) { node.error(err); }
        node.db = db;
        node.emit("connect");  // Flag to other modules when db is ready!
    });

From my node I can then use the following during initialisation:

    this.levelConfig.on('connect', function() { ... });

Welcome your thoughts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the lvldb(this.dbname, callback) initialization and the levelConfig.db access used by other modules. Check how readiness is currently exposed, then verify that consumers can listen for the proposed connect event before using get/put and that initialization errors remain reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.