how to connect field in a collection to another field collection

what i want is when client upload image in the image collection, there’s a field in the image collection showing who uploaded the image by coping his info from membership collection field to upload Image collection field .
Please Reference/Multi Reference type is not what i need because i have to choose manually from the field.
thank you.

Is the loginEmail from PrivateMembersData the same as their account log-in from Wix (i.e the email they put in when they sign up for an account)? If so, you can get the email by doing the following:

import wixUsers from'wix-users';
import wixData from'wix-data';

wixUsers.currentUser.getEmail()
.then( (email) => {
    let toSave = {
        "email":  email,
        "image":  $w('#yourImage').src
    }
    
    wixData.save("yourCollection", toSave)
})

If you need more information from the PrivateMembersData database you could do the following:

import wixUsers from'wix-users';
import wixData from'wix-data';

wixUsers.currentUser.getEmail()
.then( (email) => {

    wixData.query("PrivateMembersData")
    .eq("loginEmail", email)
    .find()
    .then( (results) => {
        let item = results.items[0]
        
        //here you can gather whatever information you            need in the following way: Say you want to get their first name from a field with the field key firstName, you would do the following:
        
        let firstName = item.firstName
        
        //then, you will set up your save information
        
        let toSave = {
            "email":  email,
            "image":  $w('#yourImage').src,
            "firstName": firstName,
        }
    
        wixData.save("yourCollection", toSave)
    })
    
})

Hope this helps :slight_smile:

i think this is useful but what have i do exactly ,do i need o copy and paste this code

or do i need to replace the name of contents? if yes what the content i have to rename and whats not

Thank you

Hi Feras,

You may have to change some things to make the example provided by Anney work on your site.

This section of the code will save an email, image and name to a collection. “email”, “image” and “firstName” are the field IDs for the collection. If your field IDs are different you will have to change the code to suit them.

“yourCollection” would be the ID for your collection where you want to save the information.

You can learn more about debugging your code with the following article.

Corvid: Testing and Debugging Your Code

Hope this helps!

Dara | Corvid Team