Skip to content

Replaces $ref in JSON objects so that they can be stored in Mongo.

Notifications You must be signed in to change notification settings

hugomd/ref-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ref Replace npm version

A module that converts $ref in JSON objects and replaces it with _ref so that it can be stored in Mongo, and vice versa.

I made this module because $ref is a standard in JSON and in Mongo.

Usage

import {replaceRefsJSON, replaceRefsMongo} from 'ref-replace';

const someJSON = {
  $ref: 'test',
  test: {
    $ref: 'test',
    test: {
      $ref: 'test'
    }
  }
};

console.log(replaceRefsJSON(someJSON))
/**
Output:
{
  _ref: 'test',
  test: {
    _ref: 'test',
    test: {
      _ref: 'test'
    }
  }
}
 */

License

MIT © Hugo Müller-Downing

About

Replaces $ref in JSON objects so that they can be stored in Mongo.

Topics

Resources

Stars

Watchers

Forks

Packages