prefix-keys

1.0.0 • Public • Published

prefix-keys

Take all the key-value pairs in an object and return a new object with the keys prefixed.

Useful for updating nested documents in MongoDB

install

    npm install --save prefix-keys

Use

"use strict";
var prefixKeys = require("prefix-keys");
 
var data = {
    country: "CA",
    province: "ON"
};
 
var update = {
    $set: prefixKeys("location.", data)
};
 
var query = {
    _id: userId
};
 
db.users.update(query, update);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.021latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.021

Package Sidebar

Install

npm i prefix-keys

Weekly Downloads

21

Version

1.0.0

License

ISC

Last publish

Collaborators

  • rangermauve