Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ MongoDB cheat sheet

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š MongoDB cheat sheet


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Here is a cheat sheet for mongodb

Basic Idea

Database: A container of collection.
Collection: Grouping of documents insida of a database. Similar tables in SQL.
Document: A record inside of a collection. Similar to row in SQL.
Field: A key value pair within a document. Similar to column in SQL.

Basic commands

mongosh: A JavaScript shell for interacting with MongoDB instances. It provides a command-line interface (CLI) that allows you to connect to a MongoDB server.
show dbs: Shows all databases in the current MongoDB instance.
use <dbname>: Switch database provided by dbname.
db: Shows current database name.
show collections: Shows all collections.
db.dropDatabase(): Deletes the current database.
exit: Exits the mongosh session.

Create

insertOne: Creates a document within the specified collection.

db.users.insertOne({ name: โ€œArafatโ€ })
// Create a document with the name of Arafat into the users collection

insertMany: Creates multiple documents within the specified collection.

db.users.insertMany([{ name: โ€œJohnโ€ }, { age: โ€œRoyโ€ }])
// Create two documents with the name John and Roy into the users collection

Read

find: Get all documents.

db.users.find()

find(<filterObject>): Find all documents based on the filter object

db.users.find({ name: โ€œArafatโ€ })
// Get all users with the name Arafat
db.users.find({ โ€œaddress.streetโ€: โ€œ434 Lund Swedenโ€ })
// Get all users whose adress field has a street field with the value 434 Lund Sweden

find(<filterObject>, <selectObject>): Find all documents that match the filter object but only return the field specified in the select object

db.users.find({ name: โ€œArafatโ€ }, { name: 1, hobby: 1 })
// Get all users with the name Arafat but only return their name, hobby, and _id
db.users.find({}, { hobby: 0 })
// Get all users and return all fields except for hobby

findOne: Returns the first document that matches the filter object.

db.users.findOne({ name: โ€œArafatโ€ })
// Get the first user with the name Arafat

countDocuments: Returns the count of the documents that match the filter object.

db.users.countDocuments({ name: โ€œArafatโ€ })
// Get the number of users with the name Arafat

Update

updateOne: Updates the first document.

db.users.updateOne({ name: "Arafat" }, { $set: { name: "Theo" } })
// Update the first user with a name of Arafat to the name of Theo

updateMany: Updates multiple docments.

db.users.updateMany({ age: 16 }, { $inc: { age: 6 } })
// Update all users with an age of 16 by adding 6 to their age

replaceOne: Replace the first document. This
will completely overwrite the entire object and not just
update individual fields.

db.users.replaceOne({ age: 12 }, { age: 13 })
// Replace the first user with an age of 12 with an object that has the age of 13 as its only field

Delete

deleteOne: Delete a single document from a collection.

db.users.deleteOne({ name: "Arafat" })
// Delete the first user with an name of Arafat

deleteMany: Delete multiple documents from a collection.

db.users.deleteMany({ age: 26 })
// Delete all users with an age of 26

Complex Filter Object

$eq: equals.

db.users.find({ name: { $eq: โ€œArafatโ€ } })
// Get all the users with the name Arafat

$ne: not equal to.

db.users.find({ name: { $ne: โ€œArafatโ€ } })
// Get all users with a name other than Kyle

$gt / $gte: Greater than and greater than or eqal.

db.users.find({ age: { $gt: 26 } })
// Get all users with an age greater than 26
db.users.find({ age: { $gte: 34 } })
// Get all users with an age greater than or equal to 34

$lt / $lte: Less than and less than or eqal.

db.users.find({ age: { $lt: 26 } })
// Get all users with an age less than 26
db.users.find({ age: { $lte: 34 } })
// Get all users with an age less than or equal to 34

$in: Check if a value is one of many values.

db.users.find({ name: { $in: [โ€œRoyโ€, โ€œLeoโ€] } })
// Get all users with a name of Roy or Leo

$nin: Check if a value is none of many values.

db.users.find({ name: { $nin: [โ€œRoyโ€, โ€œLeoโ€] } })
// Get all users that do not have the name Roy or Leo

$and: Returns true if all expressions are true

db.users.find({ $and: [{ age: 6 }, { name: โ€œArafatโ€ }] })
// Get all users that have an age of 6 and the name Arafat
db.users.find({ age: 6, name: โ€œArafatโ€ })
// Alternative way to do same thing

$or: returns true if any expression is true

db.users.find({ $or: [{ age: 6 }, { name: โ€œArafatโ€ }] })
// Get all users that have an age of 6 or the name Arafat

$not: Negates the expression

db.users.find({ name: { $not: { $eq: โ€œArafatโ€ } } })
Get all users with a name other than Arafat

$exists: Matches documents that have the specified field.

db.users.find({ name: { $exists: true } })
// Returns all users that have a name field

$expr: performs an expression evaluation in the query.

db.users.find({ $expr: { $gt: [โ€œ$balanceโ€, โ€œ$debtโ€] } })
// Get all users that have a balance that is greater than their debt

Complex Update Object

$set: Updates only the fields passed to $set.

db.users.updateOne({ age: 12 }, { $set: { name: โ€œRoyโ€ } })
// Update the name of the first user with the age of 12 to the value Roy

$inc: Increments the value of a field by a specified amount.

db.users.updateOne({ debt: 200 }, { $inc: { debt: 100 } })
// Add 100 to the debt of the first user with the debt of 200
db.users.updateOne({ debt: 200 }, { $inc: { debt: -100 } })
// Remove 100 from the debt of the first user with the debt of 200

$rename: Rename a field

db.users.updateMany({}, { $rename: { loss: โ€œProfitโ€ } })
// Rename the field loss to profit for all users

$unset: Remove a field.

db.users.updateOne({ age: 26 }, { $unset: { age: "" } })
// Remove the age field from the first user with an age of 26

$push: Adds new elements to an array

db.users.updateMany({}, { $push: { enemy: โ€œRiaโ€ } })
// Add Ria to the enemy array for all users

$pull: Rmoves all array elements that match a specified condition.

db.users.updateMany({}, { $pull: { enemy: โ€œArafatโ€ } })
// Remove Mike from the friends array for all users

Modifiers for read

sort: Sort the results of a find by the given fields.

db.users.find().sort({ debt: 1, balance: -1 })
// Returns all users sorted by name in alphabetical order and then if any duplicated names exits, sorts by age in reverse order.

limit: Returns a specified number of documents.

db.users.find().limit(5)
// Returns the first 5 users

skip: Skip a specified number of documents from the start.

db.users.find().skip(7)
// Skip the first 7 users when returning results. Freat for pagination when combined with limit.
...



๐Ÿ“Œ MongoDB cheat sheet


๐Ÿ“ˆ 39.34 Punkte

๐Ÿ“Œ John the Ripper Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ A Security Professionalโ€™s Cheat Sheet for the Holidays: Hacks, Breaches and More!


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ John the Ripper Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ A Security Professionalโ€™s Cheat Sheet for the Holidays: Hacks, Breaches and More!


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Hashcat 4.10 Cheat Sheet v 1.2018.1


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Vim Cheat Sheet for Programmers


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Any cheat sheet for Linux?


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Security In 5: Episode 306 - Tools, Tips and Tricks - Linux Command Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Some Linux Commands "Cheat-sheet"


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Shellver - Reverse Shell Cheat Sheet Tool


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Best A-Z Python Cheat Sheet 2019 (Basic to Advance)


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Best A-Z Python Cheat Sheet 2019 (Basic to Advance)


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Most Important Mobile Application Penetration Testing Cheat sheet with Tools & Resources for Security Professionals


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Container Security Part 3 โ€“ Kubernetes Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Container Security Part 3 โ€“ Kubernetes Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Wireless Penetration Testing Checklist โ€“ A Detailed Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Top 500 Most Important XSS Script Cheat Sheet for Web Application Penetration Testing


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ LoL Teamfight Tactics: Cheat Sheet zeigt Items auf einen Blick โ€“ Was ist Spatula?


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ DDG gives you a cheat sheet for any chmod configuration, good for noobs like me.


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ We all have favourite editors here at work. So when I started to print out a Vim cheat sheet, others decided to join in.


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Web Application Penetration Testing Checklist โ€“ A Detailed Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ This is my personal linux commands cheat sheet. Not perfect but pretty useful for me


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Kali Linux Commands cheat sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Git: Cheat Sheet (advanced)


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Metasploit Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Never got around to learning GNU Parallel? Here is the cheat sheet (pdf).


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Metasploit Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Cheat Sheet to Make Free Fire Game More Interesting


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Cheat sheet for running rootless containers on Linux with Podman.


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ Reverse Shell Cheat Sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ I made a vi editor/grep command cheat sheet for others who are taking Linux college classes!


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ The Disney+ MCU movie marathon cheat sheet


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ SANS Cheat Sheet: Python 3


๐Ÿ“ˆ 27.25 Punkte

๐Ÿ“Œ SANS Cheat Sheet: Netcat


๐Ÿ“ˆ 27.25 Punkte











matomo