manip

2019-09-11

manip是什么

什么是manip,A library for manipulating nested data in a way reminiscent of MongoDB's "Field Update Operators" work (eg. $set)

manip使用教程帮助文档

Manip

A library for manipulating nested data in a way reminiscent of MongoDB's "Update Operators"work (eg. $set, $unset, $pushand $inc)".

The following operations are current supported:

  • $set
  • $unset
  • $push
  • $inc

Given a set of data, sometimes you want to be able to be able to modify deeply nested data without hard coding the path to that data or worring if the sub sub subdocument you want to add to already exists.

Take the following example:

var jack = {
    eyes: 'blue',
    car: {
        ford: {
            wheels: 4,
            age: 3,
            color: 'blue'
        }
    }
};

I could increase the age of the car by one year

manip(jack, {'$inc': {'car.ford.age': 1}}));

and now the data is:

{
    eyes: 'blue',
    car: {
        ford: {
            wheels: 4,
            age: 4,
            color: 'blue'
        }
    }
}

Source Code

Source code is prepared using Browserifywhich is also compatible with Node.JS. There is a UMD bundle which can be used with AMD or a vanilla browser (where it will export a global called manip.


上一篇:get_tlid_encoder_decoder
下一篇:docker
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部