Have ideas for Embedded Object fields?

604 views
Skip to first unread message

Bill Crews

unread,
Oct 13, 2023, 12:28:51 AM10/13/23
to mementodatabase
Widgets were a great addition to Memento, but they didn't extend the library itself (much), so I haven't bothered to learn much about them.

But now, with 5.1, we have an embedded object field type. Now that's really interesting! It sounds great, but what does it really enable us to do that we couldn't do before? I checked Help, and nothing was said about embedded objects.

So, I started playing with them. I created a library with a Name field identifying a person. I then added an embedded object field for Siblings, Parents, Children, & Grandchildren. For each of them, I used a Name (Text) attribute and a Birthdate (Date) attribute.

The main thing I noticed was that there are fewer attribute types than there are field types, so what's not allowed in an embedded object? The following types can only be in fields, not in EO attributes...

Calculation, JavaScript, Button, Lookup, Image, Audio, Barcode, Signature, Rich Text, Link to File, Link to Entry, List, Tree, Tags, Color, User, and of course, Embedded Object types.

Since an EO can't be an attribute of an EO, we can't use them to build a tree structure of EOs or entries. Without Calculation, JavaScript, Button, or Lookup, we can't calculate things or look up things in other libraries. The most interesting thing is that we can hyperlink.

So what can we do that we couldn't do before? As I see it, we can avoid Link to Entry fields by building a single library that is a set of entries each of which can contain object, or things with a limited number of relatively simple attributes.

So, what is it best used for? Well, I can imagine a Communities library, where each entry is for a community, like a forum, blog, or mailing list, and the fields would include a community name, maybe a bit of other info, and an embedded object for each member, with its email address, maybe phone number, etc.

Or a Products library, where each entry is for a product series and an EO for each product model in the series.

Or any other reference data where there's a primary definition of a set of things each of which consists of a set of subordinate things, but you can go only one level down, and the second level is far more limited in what it can contain.

JavaScript fields, actions, triggers, & Button fields can work on an entry-by-entry basis, but not on an EO by EO basis. Like a trigger script that can loop through links of a many-to-many Link to Entry field, a trigger script could loop through the EOs of an entry.

I'm sure some of you have given it some thought as well. What have you learned, and what ideas do you have for use of Embedded Object fields?

Tony Azrael

unread,
Oct 13, 2023, 6:16:48 PM10/13/23
to mementodatabase

Hi,

I'm afraid I haven't learned much, but I noticed that if you limit the "Max number of objects" to 1, the embedded object looks like a dictionary or a hashtable, basically an array of key-value pairs. So my first instinct is to try and access a single value in Javascript as such:

field("Frequency.Magnitude")

I tried other variations of the syntax like field("Frequency").Magnitude but doesn't work.
I wonder if it's even possible at all, there needs to be documentation. Could be useful for logic.

Er Mo

unread,
Oct 15, 2023, 3:08:17 AM10/15/23
to mementodatabase
Hallo
Hab mit den " Eingebetteten Objekt " gespielt  . Die Daten ausgelesen und in andere Felder geschrieben . Hier die Bibliothek zum Testen .

Hello
I played with the “Embedded Objects”. The data is read and written to other fields. Here is the library for testing.


Ernst

Gilles Mons

unread,
Oct 15, 2023, 4:54:05 AM10/15/23
to Er Mo, mementodatabase
Merci Ernst,

Mais nous ne pouvons pas copier la table ! Pour pouvoir faire des tests.

Gilles

Danke Ernst,

Aber wir können die Tabelle nicht kopieren! Um Tests durchführen zu können.

Gilles

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/b9951e32-0bd6-4fc1-9013-6403adb9929fn%40googlegroups.com.

Gilles Mons

unread,
Oct 15, 2023, 4:56:42 AM10/15/23
to Er Mo, mementodatabase
Ernst,

Wir haben auch keine Berechtigung, einen neuen Datensatz zu erstellen! 

Er Mo

unread,
Oct 15, 2023, 5:02:48 AM10/15/23
to mementodatabase
Hallo
Ist alles offen . Müsste gehen .

Bonjour
Tout est ouvert. Il faudrait y aller.

Ernst

Bill Crews

unread,
Oct 15, 2023, 6:53:35 AM10/15/23
to Er Mo, mementodatabase
Ich habe die Bibliothek kopiert und kann auf ihre Struktur und Skripte zugreifen, aber es sind keine eingebetteten Objektfelder vorhanden.  Vielleicht ist das die falsche Bibliothek?
__________

I copied the library and can access it's structure & scripts, but there are no embedded object fields. Maybe this is the wrong library?
__________

J'ai copié la bibliothèque et je peux accéder à sa structure et à ses scripts, mais il n'y a pas de champs d'objet incorporés.  Peut-être que ce n'est pas la bonne bibliothèque ?

Gilles Mons

unread,
Oct 15, 2023, 9:19:58 AM10/15/23
to Bill Crews, Er Mo, mementodatabase
Bill,

Le champ test1 est Un champ Object intégré.

Bill,

The test1 field is a built-in Object field.

Bill Crews

unread,
Oct 15, 2023, 2:38:38 PM10/15/23
to Gilles Mons, Er Mo, mementodatabase
Thank you, Gilles. This was an interesting experiment...

First, yesterday, I copied his library, and indie, I saw maybe 8 fields all in one page, mostly time & date fields. Three were at least 3 scripts referencing the time & date fields.

Today, when I opened the copied library, this one presumably owned by me (alias is libs/mobi/UnConnoisseur), it updated from my cloud, though I had not changed it, and now there are no time or date fields, but instead an embedded object field, a second page called WERTE, and the 3 scripts have become one. As this is a copy owned by me, I am amazed that it could be updated by others, leaving me to think that copying, though ownership changes, leaves a trail back to the original library.

Now, as to the restructured library, the script copies the attributes of the embedded object to typed field on the WERTE page. I think I have learned 2 things from the Lesen script...

var e = entry()
var etn = arg("Eintrag")
var te = e.field("Test1")
var tel =te.length
if (etn <= tel){
    var te1 = te[etn-1]
    var nam =te1.Name
    var zah =te1.Zahl
    var lis =te1.Liste
    var cod =te1.Strichcode
    e.set("Name",nam)
    e.set("Zahl",zah)
    e.set("Liste",lis)
    e.set("Strichcode",cod)
    message (nam)
}
else
    message (" Nicht Gefunden ")


One is that the argument, though an integer, send to have a length parameter and is treated as a string, tough it is treated as an integer in line 5. I confess to being confused by this.

Second, as stated previously by Tony, attributes can be referenced in JavaScript by dot notation, as they are in lines 7-10.

Thank you all for the edification.
__________

Merci, Gilles.  C'était une expérience intéressante...

Tout d'abord, hier, j'ai copié sa bibliothèque, et indépendante, j'ai vu peut-être 8 champs sur une seule page, principalement des champs d'heure et de date.  Trois étaient au moins 3 scripts faisant référence aux champs d'heure et de date.

Aujourd'hui, lorsque j'ai ouvert la bibliothèque copiée, celle-ci m'appartenant probablement (alias libs/mobi/UnConnoisseur), elle a été mise à jour depuis mon cloud, même si je ne l'avais pas modifiée, et maintenant il n'y a plus de champs d'heure ou de date, mais à la place  un champ d'objet intégré, une deuxième page appelée WERTE, et les 3 scripts ne font plus qu'un.  Comme il s'agit d'une copie qui m'appartient, je suis étonné qu'elle puisse être mise à jour par d'autres, me laissant penser que la copie, même si la propriété change, laisse une trace jusqu'à la bibliothèque d'origine.

Désormais, en ce qui concerne la bibliothèque restructurée, le script copie les attributs de l'objet incorporé dans le champ saisi de la page WERTE.  Je pense avoir appris 2 choses du script Lesen...

 var e = entry()
 var etn = arg("Eintrag")
 var te = e.field("Test1")
 var tel = te.length
 si (etn <= tel){
     var te1 = te[etn-1]
     var nom =te1.Nom
     var zah =te1.Zahl
     var lis =te1.Liste
     var cod = te1.Strichcode
     e.set("Name",nom)
     e.set("Zahl",zah)
     e.set("Liste",lis)
     e.set("Strichcode",cod)
     message (nom)
 }
 autre
     message (" Nicht Gefunden ")


La première est que l'argument, bien qu'il s'agisse d'un entier, est envoyé pour avoir un paramètre de longueur et est traité comme une chaîne, bien qu'il soit traité comme un entier à lignes 5 & 7. J'avoue être confus par cela.

Deuxièmement, comme indiqué précédemment par Tony, les attributs peuvent être référencés en JavaScript par notation par points, comme ils le sont aux lignes 7 à 10.

Merci à tous pour l'édification.
__________

Danke, Gilles.  Das war ein interessantes Experiment...

Zuerst habe ich gestern seine Bibliothek kopiert und indie sah ich vielleicht 8 Felder auf einer Seite, hauptsächlich Zeit- und Datumsfelder.  Drei waren mindestens drei Skripte, die auf die Zeit- und Datumsfelder verwiesen.

Als ich heute die kopierte Bibliothek öffnete, die vermutlich mir gehörte (Alias ​​ist libs/mobi/UnConnoisseur), wurde sie aus meiner Cloud aktualisiert, obwohl ich sie nicht geändert hatte, und jetzt gibt es keine Zeit- oder Datumsfelder, sondern stattdessen  ein eingebettetes Objektfeld, eine zweite Seite namens WERTE, und die drei Skripte sind eins geworden.  Da es sich hierbei um eine Kopie handelt, die mir gehört, wundert es mich, dass sie von anderen aktualisiert werden kann, was mich zu dem Schluss bringt, dass das Kopieren, obwohl sich der Besitzer ändert, eine Spur zurück zur Originalbibliothek hinterlässt.

Was nun die neu strukturierte Bibliothek betrifft, kopiert das Skript die Attribute des eingebetteten Objekts in das typisierte Feld auf der WERTE-Seite.  Ich glaube, ich habe aus dem Lesen-Skript zwei Dinge gelernt ...

 var e = entry()
 var etn = arg("Eintrag")
 var te = e.field("Test1")
 var tel =te.length
 if (etn <= tel){
     var te1 = te[etn-1]
     var nam =te1.Name
     var zah =te1.Zahl
     var lis =te1.Liste
     var cod =te1.Strichcode
     e.set("Name",nam)
     e.set("Zahl",zah)
     e.set("Liste",lis)
     e.set("Strichcode",cod)
     message (nam)
 }
 else
     message ("Nicht Gefunden“)

Einer davon ist, dass das Argument, obwohl es eine Ganzzahl ist, einen Längenparameter hat und als Zeichenfolge behandelt wird, obwohl es in Zeile 5 & 7 als Ganzzahl behandelt wird. Ich gebe zu, dass ich dadurch verwirrt bin.

Zweitens können Attribute, wie bereits von Tony erwähnt, in JavaScript durch Punktnotation referenziert werden, wie in den Zeilen 7–10 der Fall.

Vielen Dank an alle für die Erbauung.

Er Mo

unread,
Oct 15, 2023, 2:58:07 PM10/15/23
to mementodatabase
Hallo Bill
Die Längenangabe bezieht sich auf die Anzahl der Objekte im Eingebetteten Objekt Feld . Dies können in jeden Eintrag verschieden sein. Beim Skript wird der User gefragt welches Objekt gelesen werden soll .

Hello Bill
The length refers to the number of objects in the embedded object field. These can be different for each entry. In the script the user is asked which object should be read.

Ernst

Bill Crews

unread,
Oct 17, 2023, 9:06:51 PM10/17/23
to Er Mo, mementodatabase
Yeah, my mistake. I mistook the length and indexing as being for the integer argument in the script. Yes, similar to a many-to-many link-to-entry field, EOs present in JavaScript as an array of EOs. In your script, you accessed a specified EO in sequence, from 1 through the length of the EO array.

Now, if you instead wanted to find an EO with a Text Name argument, you could define the action with a Text argument instead of the Integer one. Then, you could use something like...

// Set these to match your EO field's attribute definition.
// These are the defaults.

const NAME = "Name";
const VALUE = "Value";

// Embedded object comparison function

const seeking = arg(NAME);
function match(element, index, array) {
    if (element[index].NAME == seeking)
    return true;
    else
    return false;
}

let eos = lib().entries();
let eo = eos.find(match);
if (eo == undefined)
message("Embedded object " + seeking + " not found");
else
message(eo.NAME + " = " + eo.VALUE);


Bill Crews

unread,
Oct 17, 2023, 9:33:17 PM10/17/23
to Er Mo, mementodatabase
I've tried EOs some more. Maybe like some of you, I have some libraries with a Text field called Notes, and if I find I want to keep additional information beyond what's in the defined fields, I just type it into the Notes field, though this info isn't really part of the library in that one can only test its value in very limited ways (like Contains).

The embedded objects (EOs) feature allows me to strip all that extra info out of the Notes field and put it into the EO field as attributes. That worked pretty well for me as far as recording the info & entering it into the attributes. The first problem I ran into was that some of my info has 2 levels. For instance, my company InterOpera has an IRS Employer ID Number (EIN) and a Business code. So I created an EO attribute called InterOpera with the value of the EIN and then the Business code on the second line of text. But now I'm combining info in something not unlike a notes field after all. I could define 2 attributes InterOpera EIN and another called InterOpera Business code, but it would have been very nice to define an attribute InterOpera containing a sub-EO with attributes EIN and Business code. Then all info would be in their own attributes but still be grouped under InterOpera. I hope that was clear. Anyway that is probably a limitation that most users can live with.

A bigger problem came in the entries list screen. There is almost no support for EO attributes in Sort, Group, or Filter. So it's as if attribute info is outside the library somewhere. I really hope the next release of Android Memento offers the ability to sort, group, and filter with attributes.

So while I wait for these abilities, I'll be concocting scripts and subordinate libraries to accomplish similar things, hopefully in a way that's still easy and effective for the user. We'll see how it goes.

I'm still interested in what you might have learned about EOs.

Reply all
Reply to author
Forward
0 new messages