Can't use database from my importer

Technical Support
  • First of all, I'm new to NodeJS development. I'm liking it so far (except for a few annoyances here and there).

    I am extending development of nodebb-plugin-import-ipboard (forked and will send a PR once it's done) to support a bunch of stuff the current plugin does not currently support, for instance:

    • IPB replies which are in a special blockquote format.
    • Spoiler blocks
    • Mentions
    • A few more things...

    On my nodebb-plugin-import-ipboard/index.js file, which I'm requiring from a manual test.js file (so it's not running inside NodeBB!), I placed a:
    var db = require('nodebb-plugin-import/server/db');

    But when I try to use it like this:
    var imported_post = db.getObject("_imported_post:1566");
    I just get "undefined".
    I can see on the debugger variables Redis is loaded (but I don't know if it was loaded correctly.)

    I also tried loading data instead of db:
    var data = require('nodebb-plugin-import/server/data');
    and
    var imported_post = data.getImportedPost("1566");

    And I just get undefined.
    Can someone tell me what I'm doing wrong?


Suggested Topics


  • 0 Votes
    3 Posts
    246 Views

    I was able to install it by following the instructions from here: https://products.containerize.com/discussion-forum/nodebb
    I already have node.js installed on my computer. I did not install redis or nginx.
    I have a mac, so on Terminal, after I created a directory called "nodebb", I skipped the first few lines of the instructions, and just pointed to the directory I created, by using the "cd" command. I then created another directory called NodeBB inside the nodebb directory. You may skip creating two directories and just create a directory called "NodeBB". I pointed to this directory by using the cd command.
    Then this line
    "git clone -b v1.15.x https://github.com/NodeBB/NodeBB.git ."
    was the key for me.
    After I typed that, nodebb was cloned to the directory.
    Then I ran "./nodebb setup".
    I used mongo for the database.
    When prompted, I pasted the connection string that I got from mongodb's site. I substituted "nodebb" for the database part in the string. (I set up mongodb (Cloud Atlas) beforehand). The instructions that come up on Terminal will tell you to call your database "nodebb".
    After that step, the program ran automatically and installed the files. It asked me to put in the username and password for mongodb and it also asked me to choose a name for admin and password. You might have to wait a while as it pauses for a long time after "Confirm Password". I thought there was some problem and was tempted to abort the operation, as it was taking a long time, but it did come up with further instructions after a while.
    I typed "./nodebb start" when the setup finished and then went to "localhost:4567", and this time, I was able to see a normal board, and could log in as admin.
    I write this follow-up in case another mac user has trouble installing nodebb. In the end, setup was pretty straightforward and did not involve a lot of steps. My OS is High Sierra.
    The instructions, including the ones for Linux, at the official nodebb site did not work for me.

  • 0 Votes
    4 Posts
    1k Views

    Sharing is caring 😛 Better to set code free ...

  • 0 Votes
    3 Posts
    1k Views

    @PitaJ thank you 🙂

  • Database

    Technical Support
    0 Votes
    2 Posts
    987 Views

    I think I was able to solve. I changed: # nano /etc/mongodb.conf
    #auth = true
    to
    auth = true

    and added to config.json

    {
    "url": "http://x.x",
    "secret": "x",
    "database": "mongo",
    "port": 4567,
    "mongo": {
    "host": "127.0.0.1",
    "port": "27017",
    "password": "XXX",
    "username": "x",
    "database": "x"
    }
    }

    if everything done correctly?

  • 0 Votes
    1 Posts
    2k Views

    Considering Redis' clustering is strictly master-slave and doesn't support multi-master, it would be nice to be able to read and write from different Redis instances.

    A very basic example: reading from the local Redis slave while writing to an external Redis master. Compared to the current situation (reading from and writing to the same Redis instance, which has to be the master because you can't write to slaves), this would result in data being returned faster from the local slave and the load on the remote master would be lowered.

    Some potential failover situations:

    Master up, slave(s) down: Read from the Master instead of the slaves Master up, one of many slaves down: Read from the node specified in the config as failover for this one, if not configured read from other slave, if all slaves are down read from master. Master down, slave(s) up: Enter a StackOverflow-esque read-only mode, 503 all requests to the yet-to-be-written Write API.