DEV Community


Posted on


Creating data specifically for each user in React / Node.js

I'm a beginner trying to create an Invoicing application. I went with React and Node/Express, and set up the authentication with Redux.

I'm currently trying to figure out how can i make it so that when a user logs in, he only sees the invoices he created himself. Because each time i connect with a different user i see the same data i previously created with another user.

What would be a solution in this case ? I thought about adding a foreign key of userId for each created invoice, is it a good idea ?

Top comments (1)

solarrris profile image

I think your solution works fine.
Another solution can be to set up an array of invoices in your user object and just show this array to the user, i think it works too.

The most important JavaScript discussions happen on DEV

React vs Signals: 10 Years Later

React vs Signals: A Look Back

☝️ Ryan Carniato and Dan Abramov take a look back at React!