Anvi Jain has Published 568 Articles

Generic way to validate textField inputs in Swift

Anvi Jain

Anvi Jain

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

3K+ Views

How often you develop an application and you write same validation for every input fields. One such example is User registration, Login screen or Registration screen or any other screen. It becomes tedious to write same line of code for every input field moreover you may tend to mistake the ... Read More

Creating an index on a nested MongoDB field?

Anvi Jain

Anvi Jain

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

2K+ Views

You can use dot(.) notation for this. Let us first create a collection with documents −> db.createIndexOnNestedFieldDemo.insertOne(    {"UserDetails":{"UserPersonalDetails":{"UserFirstName":"John", "UserLastName":"Smith"}}});    {       "acknowledged" : true,       "insertedId" : ObjectId("5ce929c778f00858fb12e916")    } > > db.createIndexOnNestedFieldDemo.insertOne( {"UserDetails":{"UserPersonalDetails":{"UserFirstName":"Chris", "UserLastName":"Brown"}}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce929d678f00858fb12e917") ... Read More

MySQL query to select a row which contains same number in a column with set of numbers separated by comma?

Anvi Jain

Anvi Jain

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

163 Views

You need to use FIND_IN_SET() for this. Let us first create a table −mysql> create table DemoTable ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(20), CustomerAllProductPrice text ); Query OK, 0 rows affected ... Read More

How can I update child objects in MongoDB?

Anvi Jain

Anvi Jain

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

925 Views

To update child objects, use $set operator. Let us first create a collection with document −>db.updateChildObjectsDemo.insertOne({"StudentName":"Chris", "StudentOtherDetails":{"StudentSubject":"MongoDB", "StudentCountryName":"AUS"}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce964e078f00858fb12e91f") }Following is the query to display all documents from a collection with the help of find() method −> db.updateChildObjectsDemo.find().pretty();This will produce the following ... Read More

How to insert only those records that does not exist in a MySQL table?

Anvi Jain

Anvi Jain

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

200 Views

To insert when a record does not exist, set the column as UNIQUE INDEX. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 ... Read More

MongoDB. max length of field name?

Anvi Jain

Anvi Jain

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

967 Views

MongoDB supports the BSON format data, so there is no max length of field name. Let us first create a collection with documents −>db.maxLengthDemo.insertOne({"maxLengthhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh":"This is demo"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ce97ac978f00858fb12e926") }Following is the query ... Read More

How to fetch only N rows at a time in MySQL?

Anvi Jain

Anvi Jain

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

724 Views

To fetch only N rows at a time, you can use LIMIT operator. Following is the syntax −select *from yourTableNameLIMIT 0, N;Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20) ... Read More

Match multiple criteria inside an array with MongoDB?

Anvi Jain

Anvi Jain

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

317 Views

For this, use aggregate framework with the $elemMatch operator. Let us first create a collection with documents −> db.matchMultipleCriteriaDemo.insertOne({    "EmployeeDetails": [       {"EmployeeName": "Chris", "Salary": 45000, "Language":"Java"},       {"EmployeeName": "Robert", "Salary": 41000, "Language":"Python"}    ] }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cea3bf0ef71edecf6a1f689") ... Read More

Select random number from a specific list in MySQL?

Anvi Jain

Anvi Jain

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

2K+ Views

You can use elt() along with rand() for this. Let us select random number from a specific list.mysql> SELECT ELT(FLOOR(RAND() * 10) + 1,    100, 200, 300, 400, 500, 600, 700, 800, 900, 1000) AS random_value_from_listOfValues;This will produce the following output −+--------------------------------+ | random_value_from_listOfValues | +--------------------------------+ | 1000 ... Read More

Query array of nested string with MongoDB?

Anvi Jain

Anvi Jain

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

214 Views

To query array of nested string, you can use the dot(.) notation. Let us first create a collection with documents −> db.nestedStringDemo.insertOne(    {       "CustomerName": "John",       "CustomerOtherDetails": [ { "Age":29, "CountryName": "US" },       { "CompanyName": "Amazon",       "Salary": 150000, ... Read More

Advertisements