Object.keys(attributes).forEach(attribute => { const appearances = _.get(attributes, [attribute, 'appearance'], {}); Object.keys(appearances).forEach(appearance => { _.set(layout, ['attributes', attribute, 'appearance'], appearances[appearance] ? appearance : '' ); }); _.unset(attributes, [attribute, 'appearance']); });
/** * @method POST * @endpoint /api/users * @description create new user * */ app.post('/api/users', (req, res, next) => { const body = req.body; app.models.user.create(body, (err, result) => { if (err === null && result) { _.unset(result, 'password'); } return err ? errorHandle(res, err, 503) : responseHandle(res, result); }); });
replace(keys) { // key 是原来的名字 if (!this.alias) { return keys; } let arr = []; for (let key of keys) { if (this.alias[key]) { this[this.alias[key]] = this[key]; lodash.unset(this, key); arr.push(this.alias[key]); } else { arr.push(key); } } return arr; }
_.each(result, async element => { await getPhasesAndPopulate(element) if (element.status !== constants.challengeStatuses.Completed) { _.unset(element, 'winners') } })
// Remove api apisToRemove.map(apiPath => { _.unset(prevSchema.models, apiPath); });
/** * Unset config in config/configuration.json file * * @param {String} variable path to the variable * @param {String} value * @param {Function} cb callback */ unSetConfig(variable, cb) { let cJSON, cFGpath = path.join(this.projectPath, '/config/configuration.json'); try { cJSON = JSON.parse(readFileSync(cFGpath)); } catch(e) { if (e.code == 'ENOENT') { writeFileSync(cFGpath, '{}'); cJSON = {}; } else { return cb(e); } } _.unset(cJSON, variable); writeFile(cFGpath, JSON.stringify(cJSON, null, 2), cb); }
it('1022: 获取子数组详情', done => { request(app) .get(`/api/v1/test/tests/${newCreateId4}/p5/${arrayPropId1}`) .end((err, res) => { if (err) return done(err) const createTime = moment(_.get(res.body, ['data', 's2', 0, 'ss3'])) assert(createTime.isValid()) _.unset(res, ['body', 'data', 's2', 0, 'ss3']) assert.deepEqual(res.body.data, { id: arrayPropId1, s1: 'key1', s2: [ { ss1: '子属性测试1-修改值1', ss2: [], id: '5e7c13ecbc1503719aa22b40' } ] }) done() }) })
// Remove previous model from the schema.layout // Usually needed when renaming a model modelsLayout.forEach(model => { if (!appModels.includes(model)) { _.unset(prevSchema, ['layout', model]); } });
const encodedPassword = _.get(user, 'password'); const passwordIsMatch = bcrypt.compareSync(password, encodedPassword); _.unset(user, 'password'); if (passwordIsMatch) {
_.unset(data, ['s2', 0, 'ss3']) assert.deepEqual(data, { id: arrayPropId1,
_.each(result, (val) => { if (!_.includes(ids, val.id)) { _.unset(val, 'privateDescription') } })
it('1024: 获取子数组对象列表', done => { request(app) .get(`/api/v1/test/tests/${newCreateId4}/p5`) .end((err, res) => { if (err) return done(err) const data = res.body.data _.unset(data, [0, 's2', 0, 'ss3']) assert.deepEqual(data, [ { id: '5e7b32820872f0498cd46256', s1: 'key1', s2: [ { id: '5e7b32820872f0498cd46255', ss1: 'ss1 原始值', ss2: [33, 76] } ] } ]) done() }) })
// Delete them from the available fields fieldsToRemove.forEach(field => { _.unset(schema, [...schemaPath, 'editDisplay', 'availableFields', field]); });
_.each(result, val => _.unset(val, 'privateDescription'))