Read and write to the database!
-
A few questions!
- Is there a standard way to write an read data from the database?
- Does it matter if I use mongodb or redis ie does some plugin only support mongo?
- Nodebb database layout for plugin data. Any good standard that I should use? How to structure data the NodeBB way?
I prefer to use as much builtin functions as possible to skit reiventing the wheel again
Is it better to learn node.js first? I only have skills for the LAMP stack
-
What's your objective in the end?
To read/write on the database (whichever you're using), with NodeBB I'd suggest you to use the "abstract layer" they developed. You can import
src/database.js
from the sources and use the native functions implemented in nodebb.To see how they structure data, I'd suggest you to go check the code of their official plugins (or directly of the platform core).
You should definitely learn Node first, IMO.
-
Unless you are doing something specific never write directly to the document store (its not as db as you know it) for one thing is not the best-structured store owing to the fact they support multiple.
As @Giggiux says use the abstraction layer this allows your plugin to work with both mongo and redis and it also allows NodeBB to change the structure of the doc store or even add more and your plugin will just work.
-
Is there any good exampels for using the abstraction layer "src/database.js". Or do i need to learn from looking into the code only?
I want to make a movie/games/database plugin for nodeBB
-
@Jenkler IMO the best example is their code!
You could replicate and modify what in NodeBB are categories as groups (Movie/games/tv show), and what in NodeBB are topics as actual elements (a movie, a tv-series, a game). The best examples of code are their one and you can find them in
/src
In order to use these things in your plugin, check official plugins code ^^
In my opinion is the best way to learn