Setup one-to-many relationship between two databases

89 views
Skip to first unread message

David Logan

unread,
Jan 29, 2026, 2:13:58 AMJan 29
to mementodatabase
Hello all,

I am trying to setup two databases so that entries from a Child (with additional detail) that match a particular field in the Parent can be displayed automatically when opened.

The Parent contains:
  • Product (text)
  • Required (boolean)
  • Qty (integer)
The Child contains
  • Product (text, many-to-one relationship with the matching field in Parent)
  • Historical date (date)
  • Historical price (currency)
What I want to do is automatically display a list of historical dates and prices when I view a product in the Parent from all matching entries in the Child database

At present, I've created a one-to-many linked field in the Parent, plus a Lookup field that connects to the Product field in the Child, however I have to search for matches manually – I would like the list of matches to be displayed automatically.

Is this possible?

Thanks in advance,

David. 

Mmm

unread,
Jan 29, 2026, 4:33:26 AMJan 29
to mementodatabase
Основная библиотека, поле JS с кодом:

let list = entry().linksFrom('Child','Product');
let items = [];

list.forEach(e => {
    let date = moment(e.field('Historical date')).format('DD.MM.YYYY – ');
    let price = Number(e.field('Historical price')).toFixed(2) + ' €';

    items.push(date + price);
});

items.join('\n')

четверг, 29 января 2026 г. в 10:13:58 UTC+3, log...@gmail.com:
Scr_1.png

David Logan

unread,
Jan 31, 2026, 11:29:47 PM (12 days ago) Jan 31
to mementodatabase
Thanks @Mmm, much appreciated!

David.

David Logan

unread,
Feb 1, 2026, 12:07:08 AM (12 days ago) Feb 1
to mementodatabase
I've been trying this out and have a problem.

First, I needed to connect to the 'Child' library:
   let Historical_Prices = libByName("Child");

The issue is I'm getting an error, TypeError: Cannot find function forEach in object [object Library] not found. (Display_Historical.js#6)

The internet tells me this is because forEach requires an array, which means 
   list = entry().linksFrom(Historical_Prices,"Product");
must therefore not be an array.

Mmm

unread,
Feb 1, 2026, 3:27:08 AM (12 days ago) Feb 1
to mementodatabase
Поле JS должно быть в библиотеке "Parent" и содержать скрипт из примера выше.

>>> let Historical_Prices = libByName("Child");

В примере такой строки нет. При попытке обратиться в поле JS к объекту library – получите ошибку. 


>>> list = entry().linksFrom(Historical_Prices,"Product");

Должно быть:
let list = entry().linksFrom('Child','Product');
Где:
– "Child" имя библиотеки, а не объект библиотека;
– "Product" имя поля–связи в библиотеке "Child".
Оба имени должны быть в кавычках. Все имена нужно изменить на свои.
Необходимо дать разрешение скриптам на доступ к библиотеке "Child".

воскресенье, 1 февраля 2026 г. в 08:07:08 UTC+3, log...@gmail.com:

Mmm

unread,
Feb 1, 2026, 3:31:11 AM (12 days ago) Feb 1
to mementodatabase
Не забудьте включить в поле JS переключатель "Выполнять в реальном времени".

воскресенье, 1 февраля 2026 г. в 11:27:08 UTC+3, Mmm:
Reply all
Reply to author
Forward
0 new messages