ref-replace
v1.0.3
Published
Replace JSON references with _ref so that the object can be inserted into Mongo
Downloads
4
Readme
Ref Replace
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