Gathering detailed insights and metrics for @atomkg077/egg-mongoose
Gathering detailed insights and metrics for @atomkg077/egg-mongoose
Gathering detailed insights and metrics for @atomkg077/egg-mongoose
Gathering detailed insights and metrics for @atomkg077/egg-mongoose
npm install @atomkg077/egg-mongoose
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
442 Stars
45 Commits
104 Forks
25 Watchers
4 Branches
35 Contributors
Updated on Apr 18, 2025
Latest Version
3.6.0
Package Id
@atomkg077/egg-mongoose@3.6.0
Unpacked Size
15.84 kB
Size
5.96 kB
File Count
11
NPM Version
6.14.18
Node Version
14.21.3
Published on
Jun 19, 2023
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
2
Egg's mongoose plugin.
Forked from egg-mongoose
1$ npm i @atomkg077/egg-mongoose --save
Change {app_root}/config/plugin.js
to enable egg-mongoose
plugin:
1exports.mongoose = { 2 enable: true, 3 package: 'egg-mongoose', 4};
1// {app_root}/config/config.default.js 2exports.mongoose = { 3 url: 'mongodb://127.0.0.1/example', 4 options: {}, 5 // mongoose global plugins, expected a function or an array of function and options 6 plugins: [createdPlugin, [updatedPlugin, pluginOptions]], 7}; 8// recommended 9exports.mongoose = { 10 client: { 11 url: 'mongodb://127.0.0.1/example', 12 options: {}, 13 // mongoose global plugins, expected a function or an array of function and options 14 plugins: [createdPlugin, [updatedPlugin, pluginOptions]], 15 }, 16};
1// {app_root}/app/model/user.js 2module.exports = app => { 3 const mongoose = app.mongoose; 4 const Schema = mongoose.Schema; 5 6 const UserSchema = new Schema({ 7 userName: { type: String }, 8 password: { type: String }, 9 }); 10 11 return mongoose.model('User', UserSchema); 12} 13 14// {app_root}/app/controller/user.js 15exports.index = function* (ctx) { 16 ctx.body = yield ctx.model.User.find({}); 17}
1// {app_root}/config/config.default.js 2exports.mongoose = { 3 clients: { 4 // clientId, access the client instance by app.mongooseDB.get('clientId') 5 db1: { 6 url: 'mongodb://127.0.0.1/example1', 7 options: {}, 8 // client scope plugin array 9 plugins: [] 10 }, 11 db2: { 12 url: 'mongodb://127.0.0.1/example2', 13 options: {}, 14 }, 15 }, 16 // public scope plugin array 17 plugins: [] 18};
1// {app_root}/app/model/user.js 2module.exports = app => { 3 const mongoose = app.mongoose; 4 const Schema = mongoose.Schema; 5 const conn = app.mongooseDB.get('db1'); 6 7 const UserSchema = new Schema({ 8 userName: { type: String }, 9 password: { type: String }, 10 }); 11 12 return conn.model('User', UserSchema); 13} 14 15// {app_root}/app/model/book.js 16module.exports = app => { 17 const mongoose = app.mongoose; 18 const Schema = mongoose.Schema; 19 const conn = app.mongooseDB.get('db2'); 20 21 const BookSchema = new Schema({ 22 name: { type: String }, 23 }); 24 25 return conn.model('Book', BookSchema); 26} 27 28// app/controller/user.js 29exports.index = function* (ctx) { 30 ctx.body = yield ctx.model.User.find({}); // get data from db1 31} 32 33// app/controller/book.js 34exports.index = function* (ctx) { 35 ctx.body = yield ctx.model.Book.find({}); // get data from db2 36}
see config/config.default.js for more detail.
1// {app_root}/config/config.default.js 2exports.mongoose = { 3 client: { 4 url: 'mongodb://mongosA:27501,mongosB:27501', 5 options: { 6 mongos: true, 7 }, 8 }, 9};
Please open an issue here.
If you are a contributor, follow CONTRIBUTING.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 14/30 approved changesets -- score normalized to 4
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
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