Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo| {"version":1,"resource":"file:///Users/santospatrick/Developer/gallery/.env.local","entries":[{"id":"qb39.local","timestamp":1649037573993},{"id":"mdDN.local","timestamp":1649183192753}]} |
| /** | |
| * React | |
| */ | |
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| /** | |
| * Generic | |
| */ | |
| import areIntlLocalesSupported from 'intl-locales-supported'; |
| /** | |
| * Redux action to store cultures | |
| * @param {Array<Object>} arr | |
| * @returns {Object} | |
| */ | |
| export const reduxAction = arr => ({ | |
| type: 'ADD_CULTURES', | |
| cultures: arr | |
| }); |
| /** | |
| * Pure javascript responsability: | |
| * http to get cultures then add it to | |
| * 'cultures' variable and then reuse | |
| * the transformers we wrote | |
| */ | |
| // Vue.js | |
| <ul> | |
| <li v-for="item in getNames(cultures)">{{ item }}</li> |
| const names = cultures.map(item => item.cultureName) | |
| // ['Soybean', 'Maize', 'Wheat'] | |
| const energies = cultures | |
| .reduce((acc, nextObject) => { | |
| const nextValue = nextObject.energy.quantity; | |
| const currentValue = acc[nextObject.energy.unit] | |
| ? acc[nextObject.energy.unit].quantity | |
| : 0; | |
| acc[nextObject.energy.unit] = { |
| const cultures = [ | |
| { | |
| cultureName: 'Soybean', | |
| quantity: 1500.50, | |
| calories: 446, | |
| energy: { | |
| quantity: 0, | |
| unit: 'g' | |
| } | |
| }, |
| /** | |
| * Get cultures name into a new array | |
| * Immutable, pure | |
| * @param {Array} cultures | |
| * @returns {Array<String>} | |
| */ | |
| const getNames = cultures => cultures.map(item => item.cultureName); | |
| /** | |
| * Get cultures quantity summed into |
| import removeAccents from 'remove-accents'; | |
| /** | |
| * Filter list based on certain attribute by some text | |
| * @param {array} list | |
| * @param {string} searchText | |
| * @param {string} attribute | |
| * @returns {array} new filtered list | |
| */ | |
| export function filterList(list, searchText, attribute) { |
Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo