Gathering detailed insights and metrics for ifnode-mongoose
Gathering detailed insights and metrics for ifnode-mongoose
Gathering detailed insights and metrics for ifnode-mongoose
Gathering detailed insights and metrics for ifnode-mongoose
npm install ifnode-mongoose
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
11 Commits
1 Watchers
14 Branches
1 Contributors
Updated on Jul 30, 2020
Latest Version
1.2.0
Package Id
ifnode-mongoose@1.2.0
Size
3.12 kB
NPM Version
5.5.1
Node Version
8.9.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
ifnode-mongoose
is a schema plugin which is specified for ifnode
and provide possibility to using mongoose
in ifnode
eco-system. Plugin does not around developer under some special features of mongoose
and it more like proxy.
Each ifnode
model (returned by app.Model
) is a abstraction under Mongoose.Schema
and Mongoose.Model
. ifnode-mongoose
get possibility to reuse any mongoose
plugins, validation and all other features.
1npm install ifnode-mongoose --save
ifnode
database connection config optionsName | Type | Description |
---|
string
| Mongo connection uri. Read more on mongoose site
config
| Object: { uri, options }
| Mongoose connect params. Read more on mongoose site (uri
- first argument of mongoose.connect(uri, options)
, options
- second argument of mongoose.connect(uri, options)
);function
| Adds possibility to create own connection. Useful for multiplied mongo connectionsstring
1module.exports = { 2 db: { 3 my_mongo_database: { 4 schema: 'mongoose', 5 config: 'mongodb://root:123@localhost:27017/db' 6 } 7 } 8};
Object
1module.exports = { 2 db: { 3 my_mongo_database: { 4 schema: 'mongoose', 5 config: { 6 uri: 'mongodb://localhost:27017/db', 7 options: { 8 user: 'root', 9 pass: '123' 10 } 11 } 12 } 13 } 14};
function
1module.exports = { 2 db: { 3 my_mongo_database: { 4 schema: 'mongoose', 5 config(Mongoose) { 6 Mongoose.set('debug', true); 7 Mongoose.Promise = Promise; 8 9 return Mongoose.createConnection('mongodb://localhost:27017/db', { 10 user: 'root', 11 pass: '123' 12 }); 13 } 14 } 15 } 16};
1module.exports = { 2 db: { 3 connection1: { 4 schema: 'mongoose', 5 config: 'mongodb://root:123@localhost:27017/somedb1' 6 }, 7 connection2: { 8 schema: 'mongoose', 9 config: { 10 uri: 'mongodb://localhost:27017/somedb2', 11 options: { 12 user: 'root', 13 pass: '123' 14 } 15 } 16 }, 17 connection3: { 18 schema: 'mongoose', 19 config(Mongoose) { 20 return Mongoose.createConnection('mongodb://localhost:27018/db', { 21 mongos: true 22 }); 23 } 24 } 25 } 26};
ifnode
models options1const app = require('ifnode')(); 2const UsersModel = app.Model( 3 model_options, 4 db_options 5);
model_options
(required)Name | Optional | Description |
---|---|---|
collection | false | Name of collection |
name | true | Name for attaching to ifnode 's application models property (default is collection option) |
columns | true | Mongoose Schema columns. Rules for create check here |
config | true | Mongoose Schema options. List check here |
db_options
(optional)Name | Description |
---|---|
db | Which of database configuration need use (from app.config.db ). Default: first in app.config.db |
alias | Model`s alias (in app.models) |
Name | Description |
---|---|
.statics | Link to mongoose.statics |
.methods | Link to mongoose.methods |
Name | Description |
---|---|
.schema() | Return mongoose Schema (new Mongoose.Schema ) instance (result of new Mongoose.Schema ) |
.model() | Return mongoose Nodel (result of Mongoose.createConnection().Model ) |
1// config/dev.js 2module.exports = { 3 db: { 4 customers_db: { 5 schema: 'mongoose', 6 config: 'mongodb://localhost/customers' 7 }, 8 events_db: { 9 schema: 'mongoose', 10 config: 'mongodb://localhost/events' 11 } 12 } 13}
1// customers.js 2 3const app = require('ifnode')(); 4const CustomersModel = app.Model({ 5 collection: 'customers', 6 config: { 7 strict: false 8 } 9}, { 10 db: 'customers_db', 11 alias: 'UsersModel' 12}); 13const originalCustomersModel = CustomersModel.model(); 14 15originalCustomersModel.schema.path('name').validate( 16 name => /[0-9]/i.test(name), 17 'Invalid name' 18); 19 20CustomersModel.statics.findByEmail = function(email) { 21 return this.find({ email }); 22};
1// customers.js 2 3const app = require('ifnode')(); 4const EventsModel = app.Model({ 5 name: 'EventsModel', 6 collection: 'events', 7 columns: { 8 id: { 9 type: String, 10 index: true, 11 unique: true 12 }, 13 type: String 14 } 15}, { 16 db: 'events_db' 17}); 18 19EventsModel.statics.pushEvent = function(event) { 20 return this.create(event); 21};
1// app.js 2const IFNode = require('ifnode'); 3const app = IFNode({ 4 environment: 'dev' 5}); 6 7app.load(); 8app.models.UsersModel.findByEmail('test@email.com').then(users => { 9 /* do smt */ 10}); 11app.models.EventsModel.pushEvent({ 12 type: 'logsmt' 13});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More