Smita Kapse has Published 560 Articles

MongoDB print JSON without whitespace i.e. unpretty JSON?

Smita Kapse

Smita Kapse

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

529 Views

To print unpretty json, use the following syntax −var yourVariableName= db.yourCollectionName.find().sort({_id:-1}).limit(10000); while( yourVariableName.hasNext() ) {    printjsononeline(yourVariableName.next() ); };To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.unprettyJsonDemo.insertOne({"StudentName":"John", "StudentAge":21, "StudentTechnicalSkills":["C", "C++"]}); {   ... Read More

LongStream summaryStatistics() method in Java

Smita Kapse

Smita Kapse

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

74 Views

The summaryStatistics() method in the LongStream class in Java returns a LongSummaryStatistics describing various summary data about the elements of this stream.The syntax is as follows −LongSummaryStatistics summaryStatistics()Here, LongSummaryStatistics is a state object for collecting statistics such as count, min, max, etc.To use the LongStream class in Java, import the ... Read More

How can I rename a field for all documents in MongoDB?

Smita Kapse

Smita Kapse

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

230 Views

The syntax is as follows to rename a field for all documents. Here, we have used $renameLdb.yourCollectionName.update({}, {$rename:{"yourOldFieldName":"yourNewFieldName"}}, false, true);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.renameFieldDemo.insertOne({"StudentName":"John"}); {    "acknowledged" : true, ... Read More

Convert C/C++ code to assembly language

Smita Kapse

Smita Kapse

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

6K+ Views

Here we will see how to generate assembly language output from C or C++ source code using gcc.The gcc provides a great feature to get all intermediate outputs from a source code while executing. To get the assembler output we can use the option ‘-S’ for the gcc. This option ... Read More

wcspbrk() function in C/C++

Smita Kapse

Smita Kapse

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

92 Views

The wcspbrk() function is a built in function of C or C++. It searches for a set of wide characters present in a wide string in another wide string. This function is present into cwhar header file.This function takes two arguments. The first argument is destination, and the second argument ... Read More

MongoDB find by multiple array items?

Smita Kapse

Smita Kapse

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

763 Views

You can use $all operator to find by multiple array items. 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.findByMultipleArrayDemo.insertOne({"StudentFirstName":"John", "StudentLastName":"Smith",    "StudentCoreSubject":["Compiler", "Operating System", "Computer Networks"]}); {    "acknowledged" : true,    "insertedId" ... Read More

LongStream skip() method in Java

Smita Kapse

Smita Kapse

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

91 Views

The skip() method of the LongStream class returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.The syntax is as follows −LongStream skip(long numEle)Here, numEle is the number of elements to be skipped.To use the LongStream class in Java, import ... Read More

How to get distinct list of sub-document field values in MongoDB?

Smita Kapse

Smita Kapse

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

230 Views

To get distinct list of sub-document field values, you can use dot(.). The syntax is as follows −db.yourCollectionName.distinct("yourOuterFieldName.yourInnerFieldName");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.getDistinctListOfSubDocumentFieldDemo.insertOne(    ... {       ... ... Read More

Convert C/C++ program to Preprocessor code

Smita Kapse

Smita Kapse

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

357 Views

Here we will see how to generate the preprocessed or preprocessor code from the source code of a C or C++ program.To see the preprocessed code using g++ compiler, we have to use the ‘-E’ option with the g++.Preprocessor includes all of the # directives in the code, and also ... Read More

How a Preprocessor works in C/C++?

Smita Kapse

Smita Kapse

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

278 Views

Here we will see how the preprocessors are working in C or C++. Let us see what are the preprocessors.The preprocessors are the directives, which give instructions to the compiler to preprocess the information before actual compilation starts.All preprocessor directives begin with #, and only white-space characters may appear before ... Read More

Advertisements