backand

Inserting record to connected table on signup()


Imagine two tables, users and addresses. addresses is connected to users via a one-to-many relationship.

I would like to add records to addresses table on signup()

signup(firstName, lastName, email, {'what should I be' : 'what should I be'})

Does it have to be done using signup parameters? or there are other ways.


Solution

  • You can use 2 methods for that:

    1) using Back& Actions - server side logic, after you create your user signup.

    2) using your code like:

    this.backand.signup(firstName, lastName, email)
      .then((data: any) => {
        console.log('Sign up succeeded');
        //Do here the Address thing to update the addrss table...
      },
      (err: any) => {
        console.log(err)
      }
    );