Author: admin

  • MongoDB mongosh Create Collection

    Create Collection using mongosh There are 2 ways to create a collection. Method 1 You can create a collection using the createCollection() database method. Example Method 2 You can also create a collection during the insert process. Example We are here assuming object is a valid JavaScript object containing post data: This will create the “posts” collection if it does not already…

  • MongoDB mongosh Create Database

    Create Database using mongosh After connecting to your database using mongosh, you can see which database you are using by typing db in your terminal. If you have used the connection string provided from the MongoDB Atlas dashboard, you should be connected to the myFirstDatabase database. Show all databases To see all available databases, in your terminal type show dbs. Notice…

  • MongoDB Query API

    MongoDB Query API The MongoDB Query API is the way you will interact with your data. The MongoDB Query API can be used two ways: MongoDB Query API Uses You can use the MongoDB Query API to perform:

  • MongoDB Getting Started

    MongoDB MongoDB is a document database and can be installed locally or hosted in the cloud. SQL vs Document Databases SQL databases are considered relational databases. They store related data in separate tables. When data is needed, it is queried from multiple tables to join the data back together. MongoDB is a document database which…

  • MongoDB Tutorial

    A MongoDB Document Records in a MongoDB database are called documents, and the field values may include numbers, strings, booleans, arrays, or even nested documents. Example Document Learning by Examples Our “Show MongoDB” tool makes it easy to demonstrate MongoDB. It shows both the code and the result. Example Find all documents that have a…

  • PHP Exception Handling

    by

    in

    What is an Exception An exception is a signal that indicates some sort of exceptional event or error has occurred. Exceptions can be caused due to various reasons, for example, database connection or query fails, file that you’re trying to access doesn’t exist, and so on. PHP provides a powerful exception handling mechanism that allows…

  • PHP Regular Expressions

    by

    in

    What is Regular Expression Regular Expressions, commonly known as “regex” or “RegExp“, are a specially formatted text strings used to find patterns in text. Regular expressions are one of the most powerful tools available today for effective and efficient text processing and manipulations. For example, it can be used to verify whether the format of…

  • PHP JSON Parsing

    by

    in

    What is JSON JSON stands for JavaScript Object Notation. JSON is a standard lightweight data-interchange format which is quick and easy to parse and generate. JSON, like XML, is a text-based format that’s easy to write and easy to understand for both humans and computers, but unlike XML, JSON data structures occupy less bandwidth than their XML versions.…

  • PHP Magic Constants

    by

    in

    What is Magic Constants In the PHP constants chapter we’ve learned how to define and use constants in PHP script. PHP moreover also provide a set of special predefined constants that change depending on where they are used. These constants are called magic constants. For example, the value of __LINE__ depends on the line that it’s used on in…

  • PHP Classes and Objects

    by

    in

    What is Object Oriented Programming Object-Oriented Programming (OOP) is a programming model that is based on the concept of classes and objects. As opposed to procedural programming where the focus is on writing procedures or functions that perform operations on the data, in object-oriented programming the focus is on the creations of objects which contain…