Hello, in my database representing job offers, I have a field called ‘sentences’ (representing requirements for a given job offer) and this field contains an array of sentences (each table entry might have different number of those sentences)
On my dynamic side connected to that database , I would like to print all the sentences for a given row one under another like that:
so that each element of my array ‘sentences’ [‘sentence_1’, ‘sentence_2’ … ‘sentence_n’] will be displayed in a separate line one under another with lets say that little dot in the beginning(dot is not necessary).
I will be more thank grateful for some help
You can use a repeater for your purposes.
let’s say …
-you have a DB-FIELD in your DATABASE called —> ‘sentences’, which is of type → ARRAY or TAGS, doesn’t really matter
You have 5 sentences inside…
-mySentence-1
-mySentence-2
-mySentence-3
-mySentence-4
-mySentence-5
Let’s recreate this situation…
let sentenceCollection = ["mySentence-1", "mySentence-2", "mySentence-3", "mySentence-4", "mySentence-5"];
console.log("Sentence-1: sentenceCollection[0]);
console.log("Sentence-2: sentenceCollection[1]);
console.log("Sentence-3: sentenceCollection[2]);
console.log("Sentence-4: sentenceCollection[3]);
console.log("Sentence-5: sentenceCollection[4]);
To be able to use a → REPEATER for your purposes, you will have to generate a new ARRAY, carriying Objects and including an → ID ← inside it. It can consist of a counting-up index, or you use for example random IDs.
At the end it will have to look like…
let preparedRepeaterObject = [
{
"_id": "1",
"firstName": "John",
"lastName": "Doe",
"image": "http://someImageUrl/john.jpg",
"sentence":
},
{
"_id": "2",
"firstName": "Jane",
"lastName": "Doe",
"image": "http://someImageUrl/jane.jpg"
}
]
It won’t work without orange marked parameters.