Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugomd/ref-replace
Replaces $ref in JSON objects so that they can be stored in Mongo.
https://github.com/hugomd/ref-replace
json mongo ref
Last synced: 23 days ago
JSON representation
Replaces $ref in JSON objects so that they can be stored in Mongo.
- Host: GitHub
- URL: https://github.com/hugomd/ref-replace
- Owner: hugomd
- Created: 2017-03-02T23:43:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T06:32:59.000Z (over 3 years ago)
- Last Synced: 2024-04-14T05:54:05.546Z (7 months ago)
- Topics: json, mongo, ref
- Language: JavaScript
- Size: 145 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Ref Replace [![npm version](https://badge.fury.io/js/ref-replace.svg)](https://www.npmjs.com/package/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](http://json-schema.org/latest/json-schema-core.html#rfc.section.7) and in [Mongo](https://docs.mongodb.com/manual/reference/database-references/#dbrefs).
# Usage
```JavaScript
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](http://hu.md/)