How do I store new user data?

Hi,

I’m making a weight tracking app, where a user signs in and then logs their weight (and other measurements).

I have a data source (titled, LOGIN) for the login details (name and password). So, the user can sign in successfully.

But, once in, they submit their weight via form, which currently saves to another data source (titled, MEASUREMENTS).

And then a line chart is displayed based on that users’s weight data that they have tracked over time.

How do I do this?

Hi Vish,

You can connect our Line chart component to that data source with the measurements recorded. You will likely need to use a chart hook to query the data so only the data for one user is returned.

The hook you will need: Charts | Fliplet Developers Documentation

Hope this helps,
Deb

1 Like

Hi Deb,

Apologies for the late response. Your help is greatly appreciated.

So, what I’m trying to do is simply allow users to track their weight and be able to see a line graph of their data - or even a table. I don’t really have any coding knowledge so I’m not sure what to do exactly.

Here is a link to a preview of my App:

There are 2 steps in this app:

  1. New user signs up → Name, Email, Password are saved to a Data Source titled “User List”

  2. A registered user logs into their account and submits their weight for the day. Should this be stored in the same Data Source as above or stored in a new Data Source? Currently, I’m storing it in a new Data Source called “Current User Weight”. But the problem here is that how do I keep a track of which user this data belongs to?

image

So basically I have to find a way to link the the data in “Current User Weight” to the currently logged in user. Then I need to fetch that data to display in a chart.

It seems like such a basic thing to be able to store and display individual user data but it’s not.

Hi Vish,

It is simpler if you store the recorded weights in another data source like you already have. If you want to track which is the user submitting the weights to the data source then you can simply add a hidden field to the form where the users submit the weight.

Under the settings for this form field you need to select settings like below:

Help article: Form component - Fliplet Knowledge Center

This should automatically fetch the logged in users Email and store it in this second data source.

Once you have this working you can then connect the chart component to this data source and show only the logged in users data using custom JS something like this:

Fliplet.Hooks.on("beforeChartQuery", function (data) {
  return Fliplet.User.getCachedSession().then(function (session) {

    var user = _.get(session, "entries.dataSource.data");

    data.config.dataSourceQuery.query = {
      where: {
        Email: user.Email,
      },
    };
  });
});

Hope this helps,
Deb