Custom Entity for User
-
Take a look at how we store users. We increment a global user id each time a new user is created and store the user data in an object with the name
user:<userId>
and we store the userId in a sorted set. You need to do something similar for businesses.Everytime a new business is created assign it a unique id and store it at
business:<businessId>
and then also store it for the user atuid:<uid>:businesses
.It would look something like below in nodebb code. This is obviously pseudocode.
incr businessId in database setObject businness:bussinessId businessData sortedSetAdd uid:<uid>:businesses Date.now() businessId
Now you can retrieve a users business with the getSortedSetRange commands using the key
uid:<uid>:businesses
.
Copyright © 2024 NodeBB | Contributors