Nishtha Thakur has Published 564 Articles

MongoDB query to remove empty objects in an object-array?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

689 Views

You can use $pull operator for this. Let us first create a collection with documents. Here, we have also added an empty object −> db.removeEmptyObjectsDemo.insertOne(    {       "_id" :101,       "LoginDate" :new ISODate(),       "UserDetails" : [          {   ... Read More

How to concatenate all values of a single column in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

924 Views

You can use group_concat() along with concat() to concatenate all values of a single column. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows affected (0.73 sec)Insert some records ... Read More

MongoDB query to update an array element matching a condition using $push?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

354 Views

Let us first create a collection with documents −> db.updateArrayElementDemo.insertOne(    {       "UserDetails":       [          {             "UserName":"Chris",             "UserAge":23          }       ]    } ... Read More

Updating boolean value in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

459 Views

To update boolean value, you can use SET. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, isMarried boolean    ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

How to request Location Permission at runtime on iOS

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

1K+ Views

To request location Permission we will be using Apple’s CLLocationManager class. You use instances of this class to configure, start, and stop the Core Location services.You can read more about CLLocationManager class here. https://developer.apple.com/documentation/corelocation/cllocationmanageriOS apps can support one of two levels of location access.While using the app − The app can ... Read More

Find documents where all elements of an array have a specific value in MongoDB?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

92 Views

You can use find() for this. Let us first create a collection with documents −> db.findDocumentsDemo.insertOne(    {       _id: 101,       "ProductDetails": [          { "ProductValue":100 },          { "ProductValue":120 }       ]    } ); { ... Read More

Performing mathematical operations in MySQL IF then ELSE is possible?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

195 Views

For performing mathematical operations and working with conditions, you can consider CASE statement. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FruitName varchar(100),    FruitPrice int    ); Query OK, 0 rows affected (0.26 sec)Insert some records ... Read More

Convert a field to an array using MongoDB update operation?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

1K+ Views

To convert a field to an array, use $set operator. Let us first create a collection with documents −> db.convertAFieldToAnArrayDemo.insertOne({"StudentSubject":"MongoDB"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce92d7778f00858fb12e91d") }Following is the query to display all documents from a collection with the help of find() method −> db.convertAFieldToAnArrayDemo.find();This will produce ... Read More

Adding new column after a specific column and defining a default in MySQL?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

1K+ Views

You need to follow some steps to add a new column after a specific column and defining default value. In order to achieve this, you need to use ALTER command. Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More

Update a single list item of a MongoDB document?

Nishtha Thakur

Nishtha Thakur

Updated on 30-Jul-2019 22:30:26

135 Views

To update a single list item, use positional operator($). Let us first create a collection with documents −> db.updateASingleListDemo.insertOne({ _id:1, "EmployeeName":"Chris", "EmployeeDetails": [ {"EmployeeId":"EMP-101", "EmployeeSalary": 18999 }] }); { "acknowledged" : true, "insertedId" : 1 }Following is the query to display all documents from a collection with the help of ... Read More

Advertisements