Answer the question
In order to leave comments, you need to log in
Why is the array not converted using array.map?
I use this code, but the data is not converted, I don’t understand why
Order.find()
.then(orders => {
orders = orders.map((order) => {
if (order.status === 0){
order.status = 'Новый';
}
order.time = moment(order.time).format('DD MMMM YYYY');
console.log(order);
return order;
});
res.render('user', {
username: req.user.username,
title: 'Главная страница',
order: orders
});
})
.catch(err => console.log(err));
{ _id: 5a0bdde700a4c7168416e8ef,
orderId: 16,
description: 'Test',
number: 10,
information: '',
file: 'Screenshot 2017-08-21 14.48.41.png',
name: 'Vasily',
phone: '79503164233 ',
email: '',
juid: null,
prepayment: null,
time: 2017-11-21T21:00:00.000Z,
prioity: 0,
__v: 0,
action: true,
createdAt: 2017-11-15T06:25: 18.636Z,
status: 0}
Answer the question
In order to leave comments, you need to log in
In addition, I don’t quite understand if you choose in favor of a framework, then it seems like they say JS is better than PHP (I don’t know why)
I don't see any advantage. Especially for projects where it is required to perform arithmetic operations.
Judging by the question, you yourself will not be able to implement this in any form.
Judging by the question, WordPress + WooComerce + Purchased \ Free theme and attempts to customize it or OpenCart + Alteration of the base theme.
A framework for a store is, with such a formulation of the question, a frankly crappy option, because: articles, nomenclature, income \ expenses, modifications, prices, charts, reports, customers, personal accounts, discounts, bonuses, promotions, currencies, VAT, delivery services, external APIs and another wagon and another wagon and a small cart of arguments against thoughtlessly dipping into something you don't understand. For self-development, it is possible and ... necessary, probably.
Dummies are so tormented by this question, as if there is no simple answer for it.
If you need a typical solution (what has already been implemented hundreds of times on the Internet) - you need a CMS.
If you want to do something that no one has done or everyone does in their own way - a framework.
The store is, as a rule, obviously the first category.
Framework is long, but will work the way you program it.
CMS is faster to deploy, customization will be a little through the ass (most likely you will have to change the system kernel code).
If you need special functionality (some special filter, a unique admin panel, something else unique), then of course the framework is better
It's up to you to decide
. If you have knowledge (or a desire to learn), you can try to write it yourself
Well, if you don't want to figure it out, then you can sms
if there are questions about why php is better than js, then transfer the project to competent developers
An experienced developer will not create an online store from scratch on a framework if it is typical. A lot of people ask me about this too. There are already ready-made solutions. If you have a little knowledge of programming - OpenCart, wCommerce, etc., and in any case, you will need to finish it. If knowledge in the language is not enough, you take Bitrix with an online store license and you will get an almost ready-made store + uploads, etc. in 1C are already underway. As for the framework, well, here we need to understand what we want, as a rule, some systems are made on the framework, web applications for selling tickets, where there are ratings, etc.
In mongus If you want simple objects, then you needOrder.find().lean().then ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question