holofy-schema
About
MongoDB schema
-
@holofy/schema
provides models for interacting with database objects.
Usage
Install the package:
npm install @holofy/schema --save-prod
Import as necessary:
const db = require('@holofy/schema');
const models = db(config.db);
To test on dev
Add .env to project root folder
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=
DB_NAME=
Add /sandbox/index.js to project root folder
// eslint-disable-next-line import/no-extraneous-dependencies
require('dotenv').config();
const db = require('../index');
const models = db({
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
database: process.env.DB_NAME,
});
models.Skill.findOne({}).then((res) => console.log(res));
On terminal
node sandbox/index.js
Please do not commit sandbox/* and .env
Publish New Package
- Only once: In this repository: Add NPM_AUTH_TOKEN to GitLab -> Settings -> CI/CD -> Settings -> Variables
git add .
git commit
npm version [major | minor | patch]