Miss any of our Open RFC calls?Watch the recordings here! »

object-adapter

0.0.4 • Public • Published

object-adapter

Function factory for mapping object values from old paths to new paths.

Installation

npm install --save object-adapter

Usage

var Adapter = require('object-adapter');
 
var userAdapter = new Adapter({
  'objectId': 'oldData.objectId',
  'authData.hashedPassword': 'hashedPassword'
});
 
var oldUsers = [
  { objectId: '1a2b3c4d5e', authData: { hashedPassword: 'UAHIFGHeaifut72efg', sessionId: '5g6h7i8j9kl' } },
  { objectId: 'Yuvoad9UE9', authData: { hashedPassword: 'JKALDJGIj03iifhju3&', sessionId: '5g6h7i8j72h' } }
  ...
];
 
var newUsers = userAdapter(oldUsers);
 
async.each(newUsers, User.create, function(error) {
  if (error) console.error(error.stack);
 
  console.log('All new users created successfully.');
});

Keywords

none

Install

npm i object-adapter

DownloadsWeekly Downloads

0

Version

0.0.4

License

ISC

Last publish

Collaborators

  • avatar