https://github.com/alandoherty/mdf
A format for defining models through external schemas
https://github.com/alandoherty/mdf
Last synced: about 1 month ago
JSON representation
A format for defining models through external schemas
- Host: GitHub
- URL: https://github.com/alandoherty/mdf
- Owner: alandoherty
- License: mit
- Created: 2015-12-16T18:20:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-05T17:01:30.000Z (over 10 years ago)
- Last Synced: 2025-02-18T20:04:23.612Z (over 1 year ago)
- Language: JavaScript
- Size: 41 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/js/mdf)
A format for defining models through external schemas, allowing you to better interact and publish information, maintaining important characteristics such as visibility to the end user.
# Installing
```bash
$ npm install mdf
```
# Example
app.js
```
var mdf = require("../src/index");
mdf.loadFile("test.mdl", function(err) {
if (err) {
console.error("error parsing file");
console.error(mdf.getErrors());
} else {
console.log(mdf.getModels());
console.log(mdf.getEnums());
console.log(mdf.getTypeDefs());
}
});
```
test.mdl
```
import "hello.mdl";
model User : "tbl_user" {
public string firstName = "";
string lastName = "";
Email email;
bool emailVerified = false;
bool notifications;
bool blocked;
bool isPrivate;
Password password;
ref group;
array avatarUrls;
State state;
}
```
hello.mdl
```
enum State {
Potato,
Mesh,
Hole
}
typedef Email string(64)
typedef Password string(64)
```
# Testing
```bash
$ npm install mdf
$ npm test
```