Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add relation column id, because used static 'id', but id relation can be other #64

Open
adilkangerey opened this issue Jan 5, 2024 · 0 comments

Comments

@adilkangerey
Copy link

if (arrayOfIds.length) {
const relatedCollection = isM2O ? relation.related_collection : relation.collection;
const path = relatedCollection === 'directus_users' ? '/users' : items/${relatedCollection};

				if (relatedCollection) {
					let data;
					if (relatedCollection in itemCache && arrayOfIds.every(id => id in itemCache[relatedCollection])) {
						data = arrayOfIds.map(id => itemCache[relatedCollection][id]);
					} else {
						**type FilterType = {
							[key: string]: any; 
						  };
						let filter_: FilterType = {}
						//console.log('relatedCollection', relatedCollection, relation )
						let id_ = relation?.schema?.foreign_key_column? relation.schema.foreign_key_column : 'id'
						filter_[id_] ={ _in: arrayOfIds.join(',') }**
						data = (await api.get(path, {
							params: { filter: filter_ },
						})).data.data;
					}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant