George John

George John

789 Articles Published

Articles by George John

Page 30 of 79

Update two separate arrays in a document with one update call in MongoDB?

George John
George John
Updated on 15-Mar-2026 205 Views

To update two separate arrays in a MongoDB document with a single update call, use the $push operator with multiple field specifications in the update document. This allows you to add values to multiple arrays simultaneously. Syntax db.collection.update( { "query": "condition" }, { $push: { "arrayField1": "value1", "arrayField2": "value2" ...

Read More

Is it possible to rename _id field after MongoDB group aggregation?

George John
George John
Updated on 15-Mar-2026 2K+ Views

Yes, it is possible to rename the _id field after MongoDB group aggregation using the $project stage. This technique allows you to map the _id field to a new field name while excluding the original _id from the output. Syntax db.collection.aggregate([ { $project: { _id: 0, newFieldName: "$_id", otherFields: ...

Read More

How can I to know if my database MongoDB is 64 bits?

George John
George John
Updated on 15-Mar-2026 182 Views

You can use buildInfo along with runCommand to check whether your MongoDB database is running on 32-bit or 64-bit architecture. The key field to look for in the output is "bits". Syntax use admin db.runCommand("buildInfo") Example First, switch to the admin database and then run the buildInfo command ? use admin db.runCommand("buildInfo"); switched to db admin The output will display detailed build information about your MongoDB instance ? { "version" : "4.0.5", "gitVersion" : "3739429dd92b92d1b0ab120911a23d50bf03c412", ...

Read More

How to create an index with MongoDB?

George John
George John
Updated on 15-Mar-2026 236 Views

To create an index in MongoDB, use the createIndex() method (replaces the deprecated ensureIndex()). Indexes improve query performance by creating efficient data lookup structures. Syntax db.collection.createIndex( { field: 1 }, // 1 for ascending, -1 for descending { unique: true } // optional: index options ); Create Sample Collection db.createCollection("creatingUniqueIndexDemo"); { "ok" : 1 } Example: Creating ...

Read More

Clearing items in a nested MongoDB array?

George John
George John
Updated on 15-Mar-2026 180 Views

To clear items in a nested MongoDB array, use the $set operator to replace the entire array field with an empty array []. This removes all elements from the specified array field. Syntax db.collection.update( { "matchField": "value" }, { $set: { "arrayField": [] } } ); Sample Data Let us create a collection with nested arrays ? db.clearingItemsInNestedArrayDemo.insertOne({ "StudentName": "John", "StudentDetails": [ { ...

Read More

MongoDB query to return only embedded document?

George John
George John
Updated on 15-Mar-2026 461 Views

While MongoDB doesn't return only embedded documents directly, you can use projection to return specific fields and the $elemMatch operator to filter array elements that match certain conditions. Syntax db.collection.find( { "arrayField.nestedField": { $gte: value } }, { "arrayField": { $elemMatch: { "nestedField": { $gte: value } } } } ); Sample Data db.queryToEmbeddedDocument.insertOne({ "UserName": "Larry", "PostDetails": [ { "UserMessage": "Hello", "UserLikes": 8 }, ...

Read More

Increment a value in a MongoDB nested object?

George John
George John
Updated on 15-Mar-2026 546 Views

To increment a value in a MongoDB nested object, use the $inc operator combined with the $ positional operator to target the specific nested element and increment its numeric value. Syntax db.collection.update( {"nestedArray.field": "matchValue"}, { $inc: { "nestedArray.$.fieldToIncrement": incrementValue } } ); Create Sample Data Let us create a collection with a document containing nested array objects ? db.incrementValueDemo.insertOne({ "StudentName": "Larry", "StudentCountryName": "US", "StudentDetails": [ ...

Read More

How to create double nested array in MongoDB?

George John
George John
Updated on 15-Mar-2026 391 Views

To create a double nested array in MongoDB, use insertOne() or insertMany() with documents containing arrays of objects that themselves contain arrays. A double nested array means an array within an array structure. Syntax db.collection.insertOne({ "field1": "value1", "outerArray": [ { "innerField": "value", "innerArray": [ ...

Read More

Difference between strncmp() and strcmp() in C/C++

George John
George John
Updated on 14-Mar-2026 2K+ Views

Both strncmp() and strcmp() are used in C/C++ programs for lexicographical string comparison. The strcmp() compares two strings till the null character is found, whereas strncmp() only compares a specified number of characters. What is strncmp() ? The function strncmp() is used to compare left string to right string up to a number. It works same as strcmp(). It returns a value greater than zero when the matching character of left string has greater ASCII value than the character of the right string. Returns a value less than zero when the matching character of left string has lesser ASCII value ...

Read More

Using "SPELL AMOUNT" function to convert amounts in ABAP

George John
George John
Updated on 13-Mar-2026 950 Views

You can use the standard function module SPELL_AMOUNT in ABAP to convert numeric amounts into their corresponding word representations. This is particularly useful for financial documents, checks, and reports where amounts need to be displayed in written form. To access and explore this function module, use Transaction code SE37 (Function Builder) − Click on the Search icon and select Function module SPELL_AMOUNT − Key Parameters The SPELL_AMOUNT function module accepts several important parameters − ...

Read More
Showing 291–300 of 789 articles
« Prev 1 28 29 30 31 32 79 Next »
Advertisements