https://github.com/131/umod
Micro data model for nodejs
https://github.com/131/umod
Last synced: about 1 year ago
JSON representation
Micro data model for nodejs
- Host: GitHub
- URL: https://github.com/131/umod
- Owner: 131
- Created: 2016-05-17T09:38:56.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-01T15:37:22.000Z (over 8 years ago)
- Last Synced: 2025-04-18T22:26:07.524Z (about 1 year ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# umod
Micro data model mapper for nodejs, works best with [pg-aa](https://github.com/131/pg-co).
[](https://travis-ci.org/131/umod)
[](https://coveralls.io/github/131/umod?branch=master)
[](https://www.npmjs.com/package/umod)
# Example
```
const uMod = require('umod');
class File extends uMod {
//dostuff
static get sql_table() { return "some_table"; }
static get sql_key() { return "some_key"; }
}
var lnk = pg.connect("somecreds@somehost");
(async function(){
var foo = await File.instanciate(lnk, some_guid);
//results in SELECT * FROM sometable WHERE some_key=?, some_guid
//return a simple File instance with all columns as properties
var foos = await File.from_ids(lnk, [some_guid, some_other_guid]);
//same thing here
}();
```
# API
## Static instanciate
Search for a model through data connector, throw if missing
## Static from_ids
Instanciate a list of model, return a key indexed dictionnary
# TODO
* Get rich or die tryin'
# Shoutbox, keywords, SEO love
model, data model, micro model, co, sql, yks, static inheritance, pg, pg-aa, model collection, "Let's have a beer & talk in Paris"
# Credits
* [131](https://github.com/131)