FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Best practice for storing additional metadata for users

    Scheduled Pinned Locked Moved
    Q&A
    api saas
    2
    2
    1.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      saurabh.sharan1
      last edited by

      I want to store additional information about users in my application - for example, which team they are part of. Is there a built-in way to associate metadata with users in FusionAuth, or is it better to use a separate database? And for the latter option, should I use a webhook for registration events so I know when to create a new user in the separate database?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        You can use the user.data and registration.data fields to store arbitrary key value data.

        If the metadata is associated with the user, use user.data. If it is associated with the user's account for a given application, use registration.data.

        Note that this field is read/write via the API, but only readable via the administrative UI.

        Here are some notes about the limits of these fields: https://fusionauth.io/community/forum/topic/89/how-large-can-the-data-field-be-for-any-of-the-fusionauth-resources

        And for the latter option, should I use a webhook for registration events

        If you want a separate database, that's the way to do it. Listen for a webhook and create the records then.

        Whether you should use the data fields or a separate database depends on what you are trying to do. The data fields are simpler and more tightly tied to the user records. You can also query them, but you'll be writing elasticsearch queries.

        If you'd rather write straight SQL or will be storing lots and lots of data about a user (for example, their entire login history for analytics), then a separate database might work better. Of course, that's another system to maintain, so more complexity is the tradeoff.

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 1
        • First post
          Last post