Skip to content

Commit fbb1e06

Browse files
committed
support both mongoose and sequelize, rename to "hyperportal"
1 parent 4418205 commit fbb1e06

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# mngs
1+
# Hyperportal
22

33

4-
A pleasant CLI for rapid development with Mongoose.
4+
A pleasant CLI for rapid development with Sequelize or Mongoose.
55

66
![](media/mngs.gif)
77

88

99
## Quickstart
1010

1111
```
12-
$ yarn add --dev mngs
12+
$ yarn add --dev hyperportal
1313
```
1414

15-
And add the following script to your `package.json` file:
15+
And add the following script to your `package.json` file. Let's call it 'console'.
1616

1717
```json
1818
"scripts":{
19-
"mongoose":"MNGS_MODELS=config/mngs.js mngs"
19+
"console":"HYP_MODELS=config/hyperportal.js hyp"
2020
}
2121
```
2222

23-
And here's how `config/mngs.js` looks like:
23+
And here's how `config/hyperportal.js` looks like, when you're using Mongoose:
2424

2525
```javascript
2626
// connects mongoose. grab your own setup
@@ -31,9 +31,15 @@ const models = require(path.join(__dirname, '../models'))
3131
module.exports = models
3232
```
3333

34+
And now, run:
35+
36+
```
37+
$ yarn console
38+
```
39+
3440
# Usage
3541

36-
Use your models (they are exposed directly) to print `p`, log `l`, and display on a table `t`.
42+
Use your models (they are already available in the console) to print `p`, log `l`, and display on a table `t`.
3743
Additionally you can simulate a `toJSON` with `js` to see what part of your model is exposed.
3844

3945
```
@@ -51,7 +57,7 @@ Fork, implement, add tests, pull request, get my everlasting thanks and a respec
5157

5258
### Thanks:
5359

54-
To all [Contributors](https://github.com/jondot/mngs/graphs/contributors) - you make this happen, thanks!
60+
To all [Contributors](https://github.com/jondot/hyperportal/graphs/contributors) - you make this happen, thanks!
5561

5662

5763
# Copyright

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "mngs",
3-
"version": "1.0.3",
2+
"name": "hyperportal",
3+
"version": "1.0.4",
44
"description": "A pleasant CLI for rapid development with Mongoose.",
55
"main": "src/index.js",
66
"repository":{
7-
"url":"https://github.com/jondot/mngs"
7+
"url":"https://github.com/jondot/hyperportal"
88
},
99
"bin":{
10-
"mngs":"src/index.js"
10+
"hyp":"src/index.js"
1111
},
1212
"scripts": {
1313
"test": "jest",

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,25 @@ const { table } = require('table')
88

99
// we don't need to see this file.
1010
__locus_modules__.print = Object.assign(__locus_modules__.print, {
11-
file: () => {},
11+
file: () => {}
1212
})
1313

1414
const models = require(path.join(
1515
process.cwd(),
16-
process.env.MNGS_MODELS || path.join(__dirname, '../config/mngs')
16+
process.env.HYP_MODELS || path.join(__dirname, '../config/mngs')
1717
))
1818

19+
const isSequelize = Model => !!Model.QueryInterface
20+
1921
// load up models
2022
Object.assign(global, models)
2123
console.log('Models:\n=======')
2224
console.log(Object.keys(models).join('\n'))
2325

2426
const objectify = m => x => {
27+
// just always use toJSON for sequelize.
28+
m = isSequelize(x) ? 'toJSON' : m
29+
2530
if (x[m]) {
2631
return x[m]()
2732
}

0 commit comments

Comments
 (0)