
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
carabao-mongo
Advanced tools
Carabao-Mongo is a powerful TypeScript library that simplifies MongoDB operations. It provides flexible and type-safe methods for querying, inserting, updating, and deleting data, all while leveraging MongoDB's advanced capabilities like aggregation pipelines.
Install the library via NPM:
npm install carabao-mongo
import { connectDatabase, closeDatabase } from 'carabao-mongo'
const main = async () => {
await connectDatabase('mongodb://localhost:27017/mydb')
// Perform operations...
await closeDatabase()
}
main().catch(console.error)
import { getCollection } from 'carabao-mongo'
interface User {
uuid?: string
name: string
email: string
createdAt: Date
status: 'active' | 'inactive'
}
const userCollection = await getCollection<User>('users')
const userId = await userCollection.insertData(
{
name: 'John Doe',
email: 'john.doe@example.com',
createdAt: new Date(),
status: 'active'
},
['email'] // mark the email field as unique (inserting a data with an already existing email will raise an exception)
)
console.log('Inserted User ID:', userId)
const userIds = await userCollection.insertMultipleData([
{ name: 'Alice', email: 'alice@example.com', createdAt: new Date(), status: 'active' },
{ name: 'Bob', email: 'bob@example.com', createdAt: new Date(), status: 'inactive' }
])
console.log('Inserted User IDs:', userIds)
const user = await userCollection.findSingleData({
where: { email: 'john.doe@example.com' }
})
console.log('User:', user)
const activeUsers = await userCollection.findMultipleData({
where: { status: 'active' },
select: ['name', 'email'],
sort: { createdAt: 'desc' },
limit: 10
})
console.log('Active Users:', activeUsers)
const updatedCount = await userCollection.updateData(
{ status: 'inactive' }, // Filter
{ status: 'active' } // Update
)
console.log('Updated Documents:', updatedCount)
const deletedCount = await userCollection.deleteData({
status: 'inactive'
})
console.log('Deleted Documents:', deletedCount)
interface Project {
uuid?: string
name: string
createdBy: string // UUID of the user who created the project
members: string[] // UUIDs of users who are members of the project
}
const projectCollection = await getCollection<Project>('projects')
const projects = await projectCollection.findMultipleData({
join: {
createdBy: { collectionName: 'users', select: ['name', 'email'] },
members: { collectionName: 'users', select: ['name', 'email'] }
},
where: { status: 'active' }
})
// projects will now contain the joined data instead of just UUIDs
console.log('Projects with User Info:', projects)
Leverage MongoDB operators like $gte
, $regex
, and $in
for advanced queries:
const recentUsers = await userCollection.findMultipleData({
where: {
createdAt: { $gte: new Date('2024-01-01') },
name: { $regex: /john/i }
}
})
console.log('Recent Users:', recentUsers)
Use limit
and skip
for efficient pagination:
const users = await userCollection.findMultipleData({
where: { status: 'active' },
limit: 10,
skip: 20
})
console.log('Paginated Users:', users)
All methods throw descriptive errors on failure. Use try...catch
to handle them:
try {
const user = await userCollection.findSingleData({ where: { email: 'notfound@example.com' } })
console.log('User:', user)
} catch (error) {
console.error('Error:', error)
}
git clone https://github.com/TinyRabarioelina/carabao-mongo.git
npm install
npm test
Carabao-Mongo is licensed under the MIT License. See the LICENSE file for more details.
If you have any feedback, feature requests, or encounter issues, please open an issue.
This library was inspired by the incredible work of the Prisma team. Their approach to simplifying and streamlining database interactions served as a foundation for many of the ideas implemented in Carabao-Mongo. While Carabao-Mongo focuses specifically on MongoDB, Prisma’s design principles influenced the structure and philosophy of this project.
Thank you to the Prisma team for their contribution to the developer ecosystem!
FAQs
Reusable MongoDB utilities and query logic
The npm package carabao-mongo receives a total of 1 weekly downloads. As such, carabao-mongo popularity was classified as not popular.
We found that carabao-mongo demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.