Code pattern for storing and accessing the additional data in the User's document

NodeBB Development
  • 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:

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

    2. 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)

    3. If yes, overwrite the data

    4. If not, store the data

    5. 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.

    Thanks


Suggested Topics