DevDocs - API Documentation Browser

NodeBB Development

Suggested Topics

  • 0 Votes
    2 Posts

    @andrei-lopatenco You are correct, there is no Flags API at the moment... there never was one for the Write API plugin, and when it got ported into core, we didn't make one either.

    But it sounds like a good idea.

    Flags API · Issue #9649 · NodeBB/NodeBB

    e.g. POST /api/v3/flags GET/PUT /flags /flags/:flagId


    GitHub (

  • 0 Votes
    3 Posts

    I found a good way to get the user list out of mongodb. In case anyone need it:

    async function doMongoDb() { const { MongoClient } = require("mongodb"); const username = encodeURIComponent("admin"); const password = encodeURIComponent("mypassword"); const clusterUrl = "localhost:27017"; const authMechanism = "DEFAULT"; const uri = `mongodb://${username}:${password}@${clusterUrl}/?authMechanism=${authMechanism}`; const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true }); try { await client.connect(); const database = client.db("nodebb"); const objects = database.collection("objects"); // get all user const query = { _key: /^user:\d+$/ }; // select fields we want to see const options = { projection: { _id: 0, username: true, _id: false, email: true, "email:confirmed": true, joindate: true, fullname: true }, }; const cursor = objects.find(query, options); if ((await cursor.count()) === 0) { console.log("No user found!"); } // iterate over the users await cursor.forEach(user => { if (user["email:confirmed"] == 1 ) { console.dir(user); } }); } finally { // make sure we close the connection await client.close(); } } // --------------------------------------------------- function init() { try { doMongoDb(); } catch(e) { console.log(e); } } // --------------------------------------------------- init();
  • 3 Votes
    19 Posts

    If you are getting uid===-1 on the /api/config route it means your request was classified as a spider.

  • 0 Votes
    1 Posts

    I am writing a plugin.

    Can anybody pl. write the code pattern for this requirement of mine...

    When a logged in user enters some data, the backend should do the following in response:

    The user sends the data to the NodeBB backend in the following format:
    { key1: data-value1, key2: data-value2, ... }

    Get the user id of the user and check if the key1, key2, etc. already exists in the Mongo DB (the user's collection/document)

    If yes, overwrite the data

    If not, store the data

    Tell the client that the action has been taken

    Actually, it is quite simple if you're writing an app from the scratch. What I am looking for is the pattern/way the NodeBB is currently handling this scenario and I want to code using the same pattern.


  • 0 Votes
    3 Posts

    I want to store the data in NodeBB's Mongo db. It will be retrieved later and displayed on a map..