nuvira
Version:
Nuvira Database. New Database format (Readable & Easy to use), (Inbuilt Schema & constraints & rules & relations).
63 lines (58 loc) • 1.52 kB
JavaScript
import { Nuvira } from 'nuvira';
// Parse a .nuv file with sections for schema and validations
const parser1 = new Nuvira({ filePath: './test.nuv', sections: "schema" });
parser1.parse()
.then(parserResult => {
console.log("Parsed Result (test1):");
console.log(JSON.stringify(parserResult, null, 2));
// Expected output (example):
/*
{
"fileRules": {},
"schema": {
....
},
"relations": {},
"validations": {},
"records": [],
"errors": []
}
*/
})
.catch(error => {
console.error("Error during parsing:", error);
});
// Parse the full .nuv file with schema, validations, records, and metadata
const parser2 = new Nuvira({ filePath: './test.nuv' });
parser2.parse()
.then(parserResult => {
console.log("Parsed Result (test2):");
console.log(JSON.stringify(parserResult, null, 2));
// Expected output (example with metadata and errors):
/*
{
"fileRules": {
"strict": false
},
"schema": {
......
},
"relations": {
......
},
"validations": {
.......
},
"records": [
......
],
"errors": [],
"metadata": {
......
}
}
*/
})
.catch(error => {
console.error("Error during parsing:", error);
});