Inspecting mongo db on server, and keys?


  • I want to know if the chats are stored encrypted or in normal text
    To go to the Mongodb (in var/lib on ubuntu)
    what command can I use to list all the keys
    and then what command to display search on a chat key (whatever that should be)?


  • is there a simple terminal program I can npm install to inspect a database?

    I got this far manually
    show dbs
    admin 0.000GB
    config 0.000GB
    local 0.141GB
    nodebb 0.002GB

    the nodebb seems very small given I have already uploaded some posts and photos on the forum?
    what data may be stored in local? it is much bigger but I dont have anything else running on that machine?

    The nodebb has collections:
    objects
    searchpost
    searchtopic
    sessions

    Which one are the chats stored in?

  • NodeBB Admin

    You can see the chat messages with db.objects.find({_key: /^message:\d+/}).pretty();

    You can use nodebb-plugin-db-explorer and use its UI to explore the database.

    image.png


  • @eveh

    the nodebb seems very small given I have already uploaded some posts and photos on the forum?
    what data may be stored in local? it is much bigger but I dont have anything else running on that machine?
    Photos aren't stored in the database directly (they're usually just stored along NodeBB files in a dedicated folder, but some plugins may change it to use cloud storage etc.), so all you're left with are some bits of text, which doesn't take that much space.

    Don't get me wrong - the DB can grow quite a bit, it just requires a lot of posts.

    While your main question was answered already, I'll just note that you can find more on NodeBB DB schema in the documentation: https://docs.nodebb.org/development/database-structure/


  • @baris said in Inspecting mongo db on server, and keys?:

    db.objects.find({_key: /^message:\d+/}).pretty();

    This was very useful.
    Could you possibly explain what the / ^ is doing ?

    and Im guessing \d+/ somehow means any numerical value ?
    it seems like the keys are message: with a number after it ?

  • NodeBB Admin

    That is just a regular expression, ^message: means find keys starting with message: and \d+ means followed by one or more numbers. So it matches the keys that are in this format message:1, message:2 etc.


  • ok but why the ^
    the key doesnt have any ^ in it so whats the /^ for
    Thanks

  • NodeBB Admin

    ^ means starts with, without that it would match stuff like user:message:3. With ^ at the beginning it only finds keys that start with message:. It also lets mongodb use indexes so that the query is faster.


Suggested Topics

| | | |