Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@mayajs/mongo
Advanced tools
A MayaJS module and service that deals with Mongodb drivers. It uses mongoose
as its core dependency to communicate with the database.
npm i @mayajs/mongo
MayaJS uses custom modules to add functionality on its core. You can use MongoDbModule
and import in on any MayaJS module in your project.
import { MongoDbModule } from "@mayajs/mongo";
import { Schema } from "mongoose";
// Define schema for mongoose
const User = new Schema({
name: String,
email: String,
password: String,
});
const mongodbOptions = {
connectionString: "your-mongodb-connection-string",
name: "your-collection-name",
options: {
// Any mongoose options can be used here
// i.e. useUnifiedTopology: true, useNewUrlParser: true, useFindAndModify: false
},
schemas: [
{
name: "User", // Name of model
schema: User, // Mongoose Schema
},
,
],
};
@Module({
imports: [MongoDbModule.forRoot(mongodbOptions)],
})
class CustomModule {}
To use mongodb inside your controller you will need to import MongoDbServices
. MongoDbServices provides set of functionality to access, manipulate and interact with mongodb.
MongoDbServices provides a database
function to access a specific collection in mongodb.
import { MongoDbServices } from "@mayajs/mongo";
@Controller()
class UsersController {
// Inject MongoDbServices in a controller
constructor(private mongo: MongoDbServices) {}
sample() {
// Get specific collection in mongodb
const db = this.mongo.database("your-collection-name");
}
}
To access a model you will need first the get the collection instance that we get from the above example. On the db instance you can access the model
object like seen below.
sample() {
// Get specific collection in mongodb
const db = this.mongo.database("your-collection-name");
// Get specific model instance
const model = db.instance.model("your-model-name");
}
This model instance is based on Mongoose Model. All of mongoose functionality is available for this model instance.
See collaborating guides here.
Author and maintainer Mac Ignacio
FAQs
MayaJS Mongo decorators and modules
The npm package @mayajs/mongo receives a total of 1 weekly downloads. As such, @mayajs/mongo popularity was classified as not popular.
We found that @mayajs/mongo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.