Best way to store plugin data in database in context of compatibility
-
Hi all.
My plugin, apart from the general configuration that can be stored in a typical mechanism created for this purpose, needs to save certain data to the database during its operation.Explaining.
I have a collection of objects, let's call them X. Each object X has several related topics and users (the data from them needs to be rendered in the profile). In addition, each X object is associated with a specific number of sections on the forum.
The number of X objects is unlimited, they can be created as a result of user actions.I have a few questions.
- Do I understand correctly that I should simply save the collection of X objects like any other data in NodeBB, using its abstract data access mechanisms?
- Can I expand the user data, topic, posts, etc. with an additional field in the database (probably containing the id of related X objects so that I can immediately ask about the right objects)?
My question is mainly aimed at the compatibility of the database and engine version, can such exact data spoil things when updating (assuming, of course, no name collision)?
-
- Do I understand correctly that I should simply save the collection of X objects like any other data in NodeBB, using its abstract data access mechanisms?
Yes, just use the
db.setObject
and other methods available, this ensures your plugin works on redis/psql/mongodb.- Can I expand the user data, topic, posts, etc. with an additional field in the database (probably containing the id of related X objects so that I can immediately ask about the right objects)?
Yes, some plugins like QnA do this and add solved/isQuestion fields into the topic objects.
NodeBB is very flexible in terms of data structure.
-