Find Documents with Arrays Not Containing a Specific Field Value in MongoDB

Smita Kapse
Updated on 30-Jul-2019 22:30:25

906 Views

You can use $nin operator for this. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.documentWithAParticularFieldValueDemo.insertOne(    ... {       ...       ... "StudentId" : 101,       ... "StudentDetails" :       ... [          ... {             ... "TheoryMarks": 78,             ... "PracticalMarks": 91          ... },          ... {             ... Read More

Dangling, Void, Null and Wild Pointers in C++

George John
Updated on 30-Jul-2019 22:30:25

3K+ Views

Dangling pointerDangling pointer is a pointer pointing to a memory location that has been freed (or deleted). There are different ways where Pointer acts as dangling pointerFunction CallThe pointer pointing to local variable becomes dangling when local variable is not static.int *show(void) {    int n = 76; /* ... */ return &n; }OutputOutput of this program will be garbage address.De-allocation of memoryint main() {    float *p = (float *)malloc(sizeof(float));    //dynamic memory allocation.    free(p);    //after calling free()    p becomes a dangling pointer p = NULL;    //now p no more a dangling pointer. }Variable goes ... Read More

Get Embedded Data in a MongoDB Document

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

285 Views

Following is the syntax to get the embedded data in a MongoDB documentdb.yourCollectionName.find({}, {‘yourOuterKeyName.yourInnerKeyName:1}).pretty();Let us first create a collection with documents> db.embeddedCollectionDemo.insertOne( ...    { ...       "StudentName" : "Larry", ...       "StudentDetails": { ...          "Larry1234": {"ProjectName": "Student Web Tracker"}, ...          "Larry7645": {"ProjectName": "Hospital Management System"}, ...          "Larry9879": {"ProjectName": "Library Management System"}, ... ...       } ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5c98a100330fd0aa0d2fe4c5") }Following is the query to display all documents from a collection> db.embeddedCollectionDemo.find().pretty();This ... Read More

Delete Nth Row in MySQL

Rama Giri
Updated on 30-Jul-2019 22:30:25

949 Views

To delete nth row in MySQL, use DELETE statement and work with subquery. Let us first create a table:mysql> create table DemoTable1    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(100)    -> ); Query OK, 0 rows affected (0.99 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable1(StudentName) values('Larry'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1(StudentName) values('Sam'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1(StudentName) values('Mike'); Query OK, 1 row affected (0.18 sec) mysql> ... Read More

Remove Edges in a Cyclic Graph for Linear Extension in C++

George John
Updated on 30-Jul-2019 22:30:25

234 Views

In this Program we will basically find a feedback arc set which contains edges which when removed from the graph, graph becomes directed acyclic graph.AlgorithmBegin    function checkCG(int n) :    n: number of vertices.    arr: struct graph variable.    Initialize cnt = 0 and size = (n-1).    For i = 0 to n-1       if (cnt == size)          return 0       if (arr[i].ptr == NULL)          Increase cnt.          for j = 0 to n-1             while (arr[j].ptr ... Read More

Construct Random Graph by Random Edge Selection in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:25

172 Views

In this program a random graph is generated for random vertices and edges. The time complexity of this program is O(v*e). Where v is the number of vertices and e is the number of edges.AlgorithmBegin    Develop a function GenRandomGraphs(), with ‘e’ as the    number of edges and ‘v’ as the number of vertexes, in the argument list.    Assign random values to the number of vertex and edges of the graph, Using rand() function.       Print the connections of each vertex, irrespective of the direction.       Print “Isolated vertex” for the vertex having no ... Read More

Contains Method of Septet Class in JavaTuples

Samual Sam
Updated on 30-Jul-2019 22:30:25

85 Views

The contains() method is used to search a value in Septet class.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; public class Demo {    public static void main(String[] args) {       Septet ... Read More

Fix Incorrect Datetime Value While Inserting in MySQL Table

George John
Updated on 30-Jul-2019 22:30:25

23K+ Views

To avoid the incorrect datetime value error, you can use the STR_TO_DATE() method.As we know the datetime format is YYYY-MM-DD and if you won’t insert in the same format, the error would get generated.Let us see what actually lead to this error. For this, let us create a new table. The query to create a table is as followsmysql> create table CorrectDatetimeDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > ArrivalTime datetime   - > ); Query OK, 0 rows affected (0.63 sec)The occurs when we try to include a ... Read More

Track Access Time of a Webpage Using Session in JSP

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

583 Views

This example describes how to use the HttpSession object to find out the creation time and the last-accessed time for a session. We would associate a new session with the request if one does not already exist.Example Live Demo           Session Tracking                        Session Tracking                                   Session info             Value                       ... Read More

Use toLowerCase in Android TextView

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

1K+ Views

This example demonstrate about How to use toLowerCase () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         In the above code, we have taken name as Edit text, when user click on button it will take data and Convert into lower letters.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; ... Read More

Advertisements