Insert UserID into 2 collections at same time

Hello, Ive tried like mad and can’t figure this out…

Here’s what Ive got from adding a profile page…

 // prompt the user to log in 
    wixUsers.promptLogin( {"mode": "login"} )
      .then( (user) => {
        userId = user.id;
        return user.getEmail();
      } )
      .then( (email) => {
        // check if there is an item for the user in the collection
        userEmail = email;
        return wixData.query("Member_Bio")
          .eq("_id", userId)
          .find();
      } )
      .then( (results) => {
        // if an item for the user is not found
        if (results.items.length === 0) {
          // create an item
          const toInsert = {
            "_id": userId,
            "email": userEmail
          };
          // add the item to the collection
          wixData.insert("Member_Bio", toInsert)
            .catch( (err) => {
              console.log(err);
            } );

I want to insert “_id” into a second collection at the same time WIX is adding the field to my “Member_Bio” collection. Is this possible?? This will allow me to create a dynamic page and button link for my second collection using {ID} Ive tried other methods but this would be cleanest…

PLEASE Help! :slight_smile:

Follow the code in this thread:

thanks manny, but im trying to insert an item in 2 collections at the same time, not make two rows in the same collection…