Connecting one collection to another collection

I’m trying to make different databases that are all created from 1 single database. So filling in the first complete database automatically generates these smaller individual databases, at least that is the idea. However, I can’t seem to refer to the other values? This is currently my code, but following lines do not seem to work:

‘First Name’: text → ^ .‘Databank’.‘First Name’
‘Gender’: text → ^ .‘Databank’.‘Gender’

Furthermore, the line:
‘Account ID’: text → ^ .‘Databank’
Only let’s me use an account ID thats in the Databank but does not automatically generate another collection like i hoped.

This is my entire code:

users
	anonymous
interfaces

root {
	'Users': collection ['Username'] {
		'Username': text
		'Password': text
		'User Type': stategroup (
			'Applicant' { }
			'UWV' { }
			'Company' { }
			'Partner' {
				'Partner Type': stategroup (
					'CBS' { }
					'Research' { }
					'Automotive' { }
					'Municipality' { }
				)
			 }
		)
	}
	'Databank': collection ['Account ID'] {
		'Account ID': text
		'First Name': text
		'Full Name': text
		'Gender': stategroup (
			'Male' { }
			'Female' { }
			'Other' { }
		)
		'BSN': text
		'Nationality': text
		'Streetname': text
		'House Number': text
		'Postal Code': text
		'City': text
		'Username': text
		'Password':  text
		'Benefit Status': stategroup (
			'None' { }
			'UB40' { }
			'TILL' { }
			'DIS' { }
		)
		'Email': text
		'Phone Number': text
		'CV': file
		'Highest Education': text
		'Application History': text
		'Bank Account': text
		'Unemployment Duration': number 'Years'
		'Marital Status': stategroup (
			'Married' { }
			'Unmarried' { }
		)
		'Disability': stategroup (
			'Yes' { }
			'No' { }
		)
	}
	'Employers': collection ['Account ID'] {
		'Account ID': text -> ^ .'Databank'[]
		'First Name': text -> ^ .'Databank'.'First Name'[]
		'Gender': text -> ^ .'Databank'.'Gender'[]
	}
}

numerical-types
	'Years'

You’re almost there :slight_smile:

A reference property (text -> ... 'Collection'[]) can only point to an entry in a collection. So it is not possible to directly refer to another property such as ‘First Name’ or ‘Gender’. However you can make these properties visible on screen after an entry from the Databank is chosen, or use them for further logic.

For example:

'Databank': collection ['Account ID'] {
	'Account ID': text
	'First Name': text
	'Gender': stategroup (
		'Male' { }
		'Female' { }
		'Other' { }
	)
}
'Employers': collection ['Account ID'] {
	'Account ID': text -> ^ .'Databank'[]
		@show: (
			'First Name'
			'Gender'
		)
	'First Name': text = >'Account ID'.'First Name'
}

Note that we first create a reference to the databank which we name Account ID:

'Account ID': text -> ^ .'Databank'[]

…and then we use this reference for another property, to duplicate the First Name of the referenced entry:

'First Name': text = >'Account ID'.'First Name'

The other technique uses the @show annotation to make properties of a referenced entry visible, like this:

image

1 Like

Thank you very much this worked for my text variables!
However I also have one variable called ‘CV’ in my collection which is a file.
When i try to use @show on CV i get a no valid scalar error. Which function can I use to refer to this CV file in my collection?

I hoped ‘CV’: file → ^ .‘Databank’
@show (
‘CV’
)
would work but it did not sadly

Currently files are not supported in @show, and although @identifying can be written on a file property it is not implemented yet.

What you could try to do is to derive the file property. For example:

root {
	'items with files': collection ['key'] {
		'key': text
		'file': file
	}
	'items': collection ['item'] {
		'item': text -> ^ .'items with files'[]
		'file': file = >'item'.'file'
	}
}