You are not logged in.
Pages: 1
I have a TSQLRecord with a TIntegerDynArray field.
On mustache template a need call a custom Expression Helpers and use the TIntegerDynArray field as value, then on custom Expression Helpers I need extract the TIntegerDynArray value.
I cannot found a VariantToTIntegerDynArray function or something like this to use on custom Expression Helpers.
Offline
Isn't the TSQLRecord serialized as a JSON array of integers?
It should be.
I have this TSQLRecord:
TSQLProject = class(TSQLRecordTimeStamped)
private
fTitle: RawUTF8;
fContacts: TIntegerDynArray;
...
published
property Title: RawUTF8 index 120 read fTitle write fTitle;
property Contacts: TIntegerDynArray index 1 read fContacts write fContacts;
...
end;
TSQLContact = class(TSQLSomeone)
private
fBirthDate: TDateTime;
fBirthPlace: RawUTF8;
...
public
published
property BirthDate: TDateTime read fBirthDate write fBirthDate;
property BirthPlace: RawUTF8 index 50 read fBirthPlace write fBirthPlace;
...
end;
Then I need plot a mustache template using the Project data but also some contacts data (the same project can have more contacts).
On my idea I pass project data to mustache template then use Expression Helpers with Contacts value (array of integers) to get contacts data.
Is this the right approach? How deserialize the Json array?
Offline
Use a Mustache loop over the array.
Please check the context data as JSON, and read again the docs about Mustache.
You don't need helpers here, I'm quite sure!
I cannot use a Mustache loop.
On Mustache template there is a Select2 input box (https://select2.org/). I need fill it with all contacts of my DB then select only contacts assigned to project.
To do it I thought to pass all array to Expression Helpers then use it for: 1. extract all contacts name from DB, 2. create all HTML about Select2 "option" and flag as "selected" the contact by TSQLProject.Contacts value.
To do it I need use array value on Expression Helpers but I cannot understand how handle array from variant.
Offline
Using such an expression helper to query the DB is some kind of breaking of the whole Mustache concept... it should be done before apply the template, in the data context.
Anyway...
Use _Safe()^ then you can use for j := 0 to Count - 1 then VariantToInt64(Values[j])
Offline
Using such an expression helper to query the DB is some kind of breaking of the whole Mustache concept... it should be done before apply the template, in the data context.
So I should extract contacts before and send them with project data as json, right?
Offline
Pages: 1