Split values of a field with multiple valuesUpdate MongoDB field using value of another fieldHow to include route handlers in multiple files in Express?Checking if a field contains a stringWhat is the “__v” field in Mongooseadd created_at and updated_at fields to mongoose schemasFind MongoDB records where array field is not emptynpm WARN package.json: No repository fieldHow to use a variable as a field name in mongodb-native findOne()?Find document with array that contains a specific valuemongodb group values by multiple fields

My employer faked my resume to acquire projects

Did people go back to where they were?

Have 1.5% of all nuclear reactors ever built melted down?

In general, would I need to season a meat when making a sauce?

Are these reasonable traits for someone with autism?

Why did David Cameron offer a referendum on the European Union?

Why aren't space telescopes put in GEO?

How to execute this code on startup?

Using credit/debit card details vs swiping a card in a payment (credit card) terminal

Count rotary dial pulses in a phone number (including letters)

Count Even Digits In Number

What to do when you've set the wrong ISO for your film?

I unknowingly submitted plagarised work

Simple function that simulates survey results based on sample size and probability

In the current era, do any wizards survive from 1372 DR?

Could a 19.25mm revolver actually exist?

Why do most published works in medical imaging try to reduce false positives?

What will be the real voltage along the line with a voltage source and a capacitor?

Why are C64 games inconsistent with which joystick port they use?

Why do Ryanair allow me to book connecting itineraries through a third party, but not through their own website?

Filling between two arrays with ListPointPlot3D

Does the unit of measure matter when you are solving for the diameter of a circumference?

Crossing US border with music files I'm legally allowed to possess

Where is the logic in castrating fighters?



Split values of a field with multiple values


Update MongoDB field using value of another fieldHow to include route handlers in multiple files in Express?Checking if a field contains a stringWhat is the “__v” field in Mongooseadd created_at and updated_at fields to mongoose schemasFind MongoDB records where array field is not emptynpm WARN package.json: No repository fieldHow to use a variable as a field name in mongodb-native findOne()?Find document with array that contains a specific valuemongodb group values by multiple fields






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















Im currently working on an ecommerce website and i am having trouble on rendering the report on my page.



here is my node server.js



app.get('/adminReport', function (req,res)
var transaction = []
mongoDb.collection('transactions').find().toArray(function(err,results) 

transaction =results
//console.log(results);
return res.render('adminReport.html',
transactions: transaction
);
);
);


here is my code on HTML



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
#transactions
<tr>
<td>_id</td>
<td>lastName, firstName</td>
<td>userId</td>

<td>timeOrdered</td>
<td>jobTitle</td>
<td>address , city, province, zip</td>
<td>email</td>
<td>contactNo</td>
<td>purchaseOpt</td>
<td>paymentMethod</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>cartId</td>
<td>itemName</td>
<td>quantity</td>
<td>₱price</td>
</tr>

</table>
</td>
<td>status</td>

</tr> /transactions


here is the result in chromes view-source



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
<tr>
<td>5c9711730d8f1c2287f5a439</td>
<td>Jordan, Micheal</td>
<td>12341</td>

<td>Sunday 24 Mar 1:11 PM</td>
<td>Programmer</td>
<td>123 St. Atlanta , Baguio, Kadabra, 1500</td>
<td>micheal@tesing.com</td>
<td>95057435</td>
<td>pickUp</td>
<td>cash</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>5c95cb8f36d0c71f05ddf9de,5c95d4b6d82a782747e929a3</td>
<td>Bag,Shirt</td>
<td>2,1</td>
<td>₱62,20</td>
</tr>
</table>
</td>
<td></td>

</tr>

</tbody>



i want to split the Bag and shirt on different <td>.



I am using mongoDB as my database and is it possible to split the value if only a certain field has multiple value?



 firstName: 'Micheal',
lastName: 'Jordan',
kinId: '12341',
country: 'Deployed',
contactNo: '95057435',
email: 'micheal@tesing.com',
jobTitle: 'Programmer',
address: '123 St. Atlanta',
province: 'Kadabra',
city: 'Baguio',
zip: '1500',
purchaseOpt: 'pickUp',
paymentMethod: 'cash',
timeOrdered: 'Sunday 24 Mar 1:11 PM',
cartId: [ '5c95cb8f36d0c71f05ddf9de', '5c95d4b6d82a782747e929a3' ],
itemName: [ 'Bag', 'Shirt' ],
quantity: [ '2', '1' ],
price: [ '62', '20' ] } ]


For this matter the cartId,itemName,quantity,price are the only fields with multiple value, is it possible to render it separately on my HTML page like Bag and shirt on different <td>.










share|improve this question






















  • Your schema could do with some work. Instead of having different arrays in the document, you should instead have a single array of objects. i.e items: [ _id: '5c95cb8f36d0c71f05ddf9de', name: 'Bag', quantity: 2, price: 62 , _id: '5c95d4b6d82a782747e929a3', name: 'Shirt', quantity: 1, price: 20 ]. That basically makes things easier than looping by index in processing, and later you will find you don't run into a problem with multi-key indexes in MongoDB, that you current design is prone to.

    – Neil Lunn
    Mar 24 at 5:44











  • thanks for this Neil, i'll be using this idea, thanks a lot :)

    – ryuzakii
    Mar 25 at 4:53











  • With a little digging you basically need to. Either by having that structure in the database or by running a loop over the arrays in the document at present to coerce them into that form. Apparantly mustache lacks any way to "dynamically" refer to an array element by it's index position. This means you need your data in that sort of form in order to process in your template the way you want. But it makes the most sense to simply store it in that database that way in the first place. For various other reasons as I mentioned.

    – Neil Lunn
    Mar 25 at 6:39

















0















Im currently working on an ecommerce website and i am having trouble on rendering the report on my page.



here is my node server.js



app.get('/adminReport', function (req,res)
var transaction = []
mongoDb.collection('transactions').find().toArray(function(err,results) 

transaction =results
//console.log(results);
return res.render('adminReport.html',
transactions: transaction
);
);
);


here is my code on HTML



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
#transactions
<tr>
<td>_id</td>
<td>lastName, firstName</td>
<td>userId</td>

<td>timeOrdered</td>
<td>jobTitle</td>
<td>address , city, province, zip</td>
<td>email</td>
<td>contactNo</td>
<td>purchaseOpt</td>
<td>paymentMethod</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>cartId</td>
<td>itemName</td>
<td>quantity</td>
<td>₱price</td>
</tr>

</table>
</td>
<td>status</td>

</tr> /transactions


here is the result in chromes view-source



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
<tr>
<td>5c9711730d8f1c2287f5a439</td>
<td>Jordan, Micheal</td>
<td>12341</td>

<td>Sunday 24 Mar 1:11 PM</td>
<td>Programmer</td>
<td>123 St. Atlanta , Baguio, Kadabra, 1500</td>
<td>micheal@tesing.com</td>
<td>95057435</td>
<td>pickUp</td>
<td>cash</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>5c95cb8f36d0c71f05ddf9de,5c95d4b6d82a782747e929a3</td>
<td>Bag,Shirt</td>
<td>2,1</td>
<td>₱62,20</td>
</tr>
</table>
</td>
<td></td>

</tr>

</tbody>



i want to split the Bag and shirt on different <td>.



I am using mongoDB as my database and is it possible to split the value if only a certain field has multiple value?



 firstName: 'Micheal',
lastName: 'Jordan',
kinId: '12341',
country: 'Deployed',
contactNo: '95057435',
email: 'micheal@tesing.com',
jobTitle: 'Programmer',
address: '123 St. Atlanta',
province: 'Kadabra',
city: 'Baguio',
zip: '1500',
purchaseOpt: 'pickUp',
paymentMethod: 'cash',
timeOrdered: 'Sunday 24 Mar 1:11 PM',
cartId: [ '5c95cb8f36d0c71f05ddf9de', '5c95d4b6d82a782747e929a3' ],
itemName: [ 'Bag', 'Shirt' ],
quantity: [ '2', '1' ],
price: [ '62', '20' ] } ]


For this matter the cartId,itemName,quantity,price are the only fields with multiple value, is it possible to render it separately on my HTML page like Bag and shirt on different <td>.










share|improve this question






















  • Your schema could do with some work. Instead of having different arrays in the document, you should instead have a single array of objects. i.e items: [ _id: '5c95cb8f36d0c71f05ddf9de', name: 'Bag', quantity: 2, price: 62 , _id: '5c95d4b6d82a782747e929a3', name: 'Shirt', quantity: 1, price: 20 ]. That basically makes things easier than looping by index in processing, and later you will find you don't run into a problem with multi-key indexes in MongoDB, that you current design is prone to.

    – Neil Lunn
    Mar 24 at 5:44











  • thanks for this Neil, i'll be using this idea, thanks a lot :)

    – ryuzakii
    Mar 25 at 4:53











  • With a little digging you basically need to. Either by having that structure in the database or by running a loop over the arrays in the document at present to coerce them into that form. Apparantly mustache lacks any way to "dynamically" refer to an array element by it's index position. This means you need your data in that sort of form in order to process in your template the way you want. But it makes the most sense to simply store it in that database that way in the first place. For various other reasons as I mentioned.

    – Neil Lunn
    Mar 25 at 6:39













0












0








0








Im currently working on an ecommerce website and i am having trouble on rendering the report on my page.



here is my node server.js



app.get('/adminReport', function (req,res)
var transaction = []
mongoDb.collection('transactions').find().toArray(function(err,results) 

transaction =results
//console.log(results);
return res.render('adminReport.html',
transactions: transaction
);
);
);


here is my code on HTML



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
#transactions
<tr>
<td>_id</td>
<td>lastName, firstName</td>
<td>userId</td>

<td>timeOrdered</td>
<td>jobTitle</td>
<td>address , city, province, zip</td>
<td>email</td>
<td>contactNo</td>
<td>purchaseOpt</td>
<td>paymentMethod</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>cartId</td>
<td>itemName</td>
<td>quantity</td>
<td>₱price</td>
</tr>

</table>
</td>
<td>status</td>

</tr> /transactions


here is the result in chromes view-source



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
<tr>
<td>5c9711730d8f1c2287f5a439</td>
<td>Jordan, Micheal</td>
<td>12341</td>

<td>Sunday 24 Mar 1:11 PM</td>
<td>Programmer</td>
<td>123 St. Atlanta , Baguio, Kadabra, 1500</td>
<td>micheal@tesing.com</td>
<td>95057435</td>
<td>pickUp</td>
<td>cash</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>5c95cb8f36d0c71f05ddf9de,5c95d4b6d82a782747e929a3</td>
<td>Bag,Shirt</td>
<td>2,1</td>
<td>₱62,20</td>
</tr>
</table>
</td>
<td></td>

</tr>

</tbody>



i want to split the Bag and shirt on different <td>.



I am using mongoDB as my database and is it possible to split the value if only a certain field has multiple value?



 firstName: 'Micheal',
lastName: 'Jordan',
kinId: '12341',
country: 'Deployed',
contactNo: '95057435',
email: 'micheal@tesing.com',
jobTitle: 'Programmer',
address: '123 St. Atlanta',
province: 'Kadabra',
city: 'Baguio',
zip: '1500',
purchaseOpt: 'pickUp',
paymentMethod: 'cash',
timeOrdered: 'Sunday 24 Mar 1:11 PM',
cartId: [ '5c95cb8f36d0c71f05ddf9de', '5c95d4b6d82a782747e929a3' ],
itemName: [ 'Bag', 'Shirt' ],
quantity: [ '2', '1' ],
price: [ '62', '20' ] } ]


For this matter the cartId,itemName,quantity,price are the only fields with multiple value, is it possible to render it separately on my HTML page like Bag and shirt on different <td>.










share|improve this question














Im currently working on an ecommerce website and i am having trouble on rendering the report on my page.



here is my node server.js



app.get('/adminReport', function (req,res)
var transaction = []
mongoDb.collection('transactions').find().toArray(function(err,results) 

transaction =results
//console.log(results);
return res.render('adminReport.html',
transactions: transaction
);
);
);


here is my code on HTML



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
#transactions
<tr>
<td>_id</td>
<td>lastName, firstName</td>
<td>userId</td>

<td>timeOrdered</td>
<td>jobTitle</td>
<td>address , city, province, zip</td>
<td>email</td>
<td>contactNo</td>
<td>purchaseOpt</td>
<td>paymentMethod</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>cartId</td>
<td>itemName</td>
<td>quantity</td>
<td>₱price</td>
</tr>

</table>
</td>
<td>status</td>

</tr> /transactions


here is the result in chromes view-source



<thead>
<tr>
<th>Transaction ID</th>
<th>Name</th>
<th>UserID</th>
<th>Time Ordered</th>
<th>Job Title</th>
<th>Address</th>
<th>Email Address</th>
<th>Contact Number</th>
<th>Purchase Option(Pick-up or Delivery)</th>
<th>Payment Method</th>
<th>Item Ordered</th>
<th>Status</th>
</tr>
</thead>

<tbody>
<tr>
<td>5c9711730d8f1c2287f5a439</td>
<td>Jordan, Micheal</td>
<td>12341</td>

<td>Sunday 24 Mar 1:11 PM</td>
<td>Programmer</td>
<td>123 St. Atlanta , Baguio, Kadabra, 1500</td>
<td>micheal@tesing.com</td>
<td>95057435</td>
<td>pickUp</td>
<td>cash</td>
<td>
<table>
<th>Transaction ID</th>
<th>Item Name</th>
<th>Quantity</th>
<th>Price</th>
<!-- item purchased -->
<tr>
<td>5c95cb8f36d0c71f05ddf9de,5c95d4b6d82a782747e929a3</td>
<td>Bag,Shirt</td>
<td>2,1</td>
<td>₱62,20</td>
</tr>
</table>
</td>
<td></td>

</tr>

</tbody>



i want to split the Bag and shirt on different <td>.



I am using mongoDB as my database and is it possible to split the value if only a certain field has multiple value?



 firstName: 'Micheal',
lastName: 'Jordan',
kinId: '12341',
country: 'Deployed',
contactNo: '95057435',
email: 'micheal@tesing.com',
jobTitle: 'Programmer',
address: '123 St. Atlanta',
province: 'Kadabra',
city: 'Baguio',
zip: '1500',
purchaseOpt: 'pickUp',
paymentMethod: 'cash',
timeOrdered: 'Sunday 24 Mar 1:11 PM',
cartId: [ '5c95cb8f36d0c71f05ddf9de', '5c95d4b6d82a782747e929a3' ],
itemName: [ 'Bag', 'Shirt' ],
quantity: [ '2', '1' ],
price: [ '62', '20' ] } ]


For this matter the cartId,itemName,quantity,price are the only fields with multiple value, is it possible to render it separately on my HTML page like Bag and shirt on different <td>.







node.js mongodb express mustache






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 5:29









ryuzakiiryuzakii

1




1












  • Your schema could do with some work. Instead of having different arrays in the document, you should instead have a single array of objects. i.e items: [ _id: '5c95cb8f36d0c71f05ddf9de', name: 'Bag', quantity: 2, price: 62 , _id: '5c95d4b6d82a782747e929a3', name: 'Shirt', quantity: 1, price: 20 ]. That basically makes things easier than looping by index in processing, and later you will find you don't run into a problem with multi-key indexes in MongoDB, that you current design is prone to.

    – Neil Lunn
    Mar 24 at 5:44











  • thanks for this Neil, i'll be using this idea, thanks a lot :)

    – ryuzakii
    Mar 25 at 4:53











  • With a little digging you basically need to. Either by having that structure in the database or by running a loop over the arrays in the document at present to coerce them into that form. Apparantly mustache lacks any way to "dynamically" refer to an array element by it's index position. This means you need your data in that sort of form in order to process in your template the way you want. But it makes the most sense to simply store it in that database that way in the first place. For various other reasons as I mentioned.

    – Neil Lunn
    Mar 25 at 6:39

















  • Your schema could do with some work. Instead of having different arrays in the document, you should instead have a single array of objects. i.e items: [ _id: '5c95cb8f36d0c71f05ddf9de', name: 'Bag', quantity: 2, price: 62 , _id: '5c95d4b6d82a782747e929a3', name: 'Shirt', quantity: 1, price: 20 ]. That basically makes things easier than looping by index in processing, and later you will find you don't run into a problem with multi-key indexes in MongoDB, that you current design is prone to.

    – Neil Lunn
    Mar 24 at 5:44











  • thanks for this Neil, i'll be using this idea, thanks a lot :)

    – ryuzakii
    Mar 25 at 4:53











  • With a little digging you basically need to. Either by having that structure in the database or by running a loop over the arrays in the document at present to coerce them into that form. Apparantly mustache lacks any way to "dynamically" refer to an array element by it's index position. This means you need your data in that sort of form in order to process in your template the way you want. But it makes the most sense to simply store it in that database that way in the first place. For various other reasons as I mentioned.

    – Neil Lunn
    Mar 25 at 6:39
















Your schema could do with some work. Instead of having different arrays in the document, you should instead have a single array of objects. i.e items: [ _id: '5c95cb8f36d0c71f05ddf9de', name: 'Bag', quantity: 2, price: 62 , _id: '5c95d4b6d82a782747e929a3', name: 'Shirt', quantity: 1, price: 20 ]. That basically makes things easier than looping by index in processing, and later you will find you don't run into a problem with multi-key indexes in MongoDB, that you current design is prone to.

– Neil Lunn
Mar 24 at 5:44





Your schema could do with some work. Instead of having different arrays in the document, you should instead have a single array of objects. i.e items: [ _id: '5c95cb8f36d0c71f05ddf9de', name: 'Bag', quantity: 2, price: 62 , _id: '5c95d4b6d82a782747e929a3', name: 'Shirt', quantity: 1, price: 20 ]. That basically makes things easier than looping by index in processing, and later you will find you don't run into a problem with multi-key indexes in MongoDB, that you current design is prone to.

– Neil Lunn
Mar 24 at 5:44













thanks for this Neil, i'll be using this idea, thanks a lot :)

– ryuzakii
Mar 25 at 4:53





thanks for this Neil, i'll be using this idea, thanks a lot :)

– ryuzakii
Mar 25 at 4:53













With a little digging you basically need to. Either by having that structure in the database or by running a loop over the arrays in the document at present to coerce them into that form. Apparantly mustache lacks any way to "dynamically" refer to an array element by it's index position. This means you need your data in that sort of form in order to process in your template the way you want. But it makes the most sense to simply store it in that database that way in the first place. For various other reasons as I mentioned.

– Neil Lunn
Mar 25 at 6:39





With a little digging you basically need to. Either by having that structure in the database or by running a loop over the arrays in the document at present to coerce them into that form. Apparantly mustache lacks any way to "dynamically" refer to an array element by it's index position. This means you need your data in that sort of form in order to process in your template the way you want. But it makes the most sense to simply store it in that database that way in the first place. For various other reasons as I mentioned.

– Neil Lunn
Mar 25 at 6:39












1 Answer
1






active

oldest

votes


















0














You can loop through the values of itemName, cartId, etc., in the same way you're looping through your transactions array.



So, instead of:



<td>itemName</td>


Try something like:



#itemName
<td>itemName</td>
/itemName


See the mustache docs at the section titled "Non-Empty Lists".






share|improve this answer

























  • The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

    – Neil Lunn
    Mar 24 at 6:45












  • jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

    – ryuzakii
    Mar 25 at 4:56











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320989%2fsplit-values-of-a-field-with-multiple-values%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You can loop through the values of itemName, cartId, etc., in the same way you're looping through your transactions array.



So, instead of:



<td>itemName</td>


Try something like:



#itemName
<td>itemName</td>
/itemName


See the mustache docs at the section titled "Non-Empty Lists".






share|improve this answer

























  • The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

    – Neil Lunn
    Mar 24 at 6:45












  • jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

    – ryuzakii
    Mar 25 at 4:56















0














You can loop through the values of itemName, cartId, etc., in the same way you're looping through your transactions array.



So, instead of:



<td>itemName</td>


Try something like:



#itemName
<td>itemName</td>
/itemName


See the mustache docs at the section titled "Non-Empty Lists".






share|improve this answer

























  • The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

    – Neil Lunn
    Mar 24 at 6:45












  • jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

    – ryuzakii
    Mar 25 at 4:56













0












0








0







You can loop through the values of itemName, cartId, etc., in the same way you're looping through your transactions array.



So, instead of:



<td>itemName</td>


Try something like:



#itemName
<td>itemName</td>
/itemName


See the mustache docs at the section titled "Non-Empty Lists".






share|improve this answer















You can loop through the values of itemName, cartId, etc., in the same way you're looping through your transactions array.



So, instead of:



<td>itemName</td>


Try something like:



#itemName
<td>itemName</td>
/itemName


See the mustache docs at the section titled "Non-Empty Lists".







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 5:51

























answered Mar 24 at 5:45









jknotekjknotek

453512




453512












  • The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

    – Neil Lunn
    Mar 24 at 6:45












  • jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

    – ryuzakii
    Mar 25 at 4:56

















  • The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

    – Neil Lunn
    Mar 24 at 6:45












  • jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

    – ryuzakii
    Mar 25 at 4:56
















The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

– Neil Lunn
Mar 24 at 6:45






The main problem as I saw it was that the actual issue is how to "loop" something like cartId, and then use the current array index in order to get the same matching position item from each of the other arrays in the "transaction". AFAIK the mustache philosophy is "minimal logic", and as such there is no such dynamic variable access. What you need to do is restructure the data first. Hence why it would be far better to simply store the data in MongoDB just how you want to use it in the template. Then you are just "looping" sub-items from the transaction within the template

– Neil Lunn
Mar 24 at 6:45














jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

– ryuzakii
Mar 25 at 4:56





jknotek thanks for the help, i tried this one but the outcome is still the same, but i gained new knowledge about mustache though, thank you :)

– ryuzakii
Mar 25 at 4:56



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320989%2fsplit-values-of-a-field-with-multiple-values%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해