MySQL, add a string in start of all column values Recently I come to know a very cool function in mysql that is CONCAT. There is a table in mysql database known as tbl_clients. Structure of this table is as follows: [crayon-5b77c5fedfe8d911694122/] there were more than 500 clients having website homepage URLs and all URLs
Insert a document using Node.js and mongoDB Suppose you have a mongoDB database for courses and you want to insert a record into the database using Node.js. First step is to install mongoDB driver for Node.js If it is not already installed. Please open command line and run following command. [crayon-5b77c5fee1d1f623410212/] This will install mongoDB
Node Js, MongoDb select record with findOne To select a single record from mongoDB database using findOne() function in Node Js [crayon-5b77c5fee4583116147997/] In the code below we use require function to include the module ‘mongodb’.MongoClient and is assigned to a variable MongoClient [crayon-5b77c5fee4595839529797/] After including mongodb module we have to connect to the server. Consider
$ unset operator in mogoDB In this article were going to explore how $ unset operator in mongodb is used to remove a field from a mongodb document. Syntax: [crayon-5b77c5fee5260564494221/] $unset operator is used to delete a field from a collection. Consider a collection named “users”. Suppose it has fields like “name”, “email” and
Suppose we have a collection in MongoDB database, We want to select data from collection then we can do like the program below. Suppose we have a collection ( Like table in Relational DBMS) named grades and this collection is in course database. Grades collection contains fields like _id, student, grade and so on… now
We can determine index size of a collection by using following command in mongoDB. Suppose our collection name is “students”. [crayon-5b77c5fee68c2498932351/] Our index and data both can take space in memory but it is more important that our index fit into the memory.
Suppose if you have a CSV file with large number of records and you want to import it into database collection then need to use [crayon-5b77c5fee7f82092112168/] [crayon-5b77c5fee7f94845317819/] [crayon-5b77c5fee7f9f788858899/] will specify database, [crayon-5b77c5fee7fa9200224278/] will represent contacts collection [crayon-5b77c5fee7fb4671589380/] is representing that CSV file [crayon-5b77c5fee7fbf489466210/] is representing the top line in file is header or column names.
In mongoDB we can remove a document like in SQL. In mongoDb we use remove function to remove a document. In remove function we specify some criteria that is like where clause in SQL if we want to remove a document where name is mike the we will do it like this. [crayon-5b77c5fee86ca685467382/] If
In mongoDB an update operation can be used in 4 ways 1. wholesale replacement of a document. 2. update individual field using $set operator 3. upsert – do update or insert 4. multiupdate of a document We have already read about first 3 let us look at multiupdate of a document. if we run following
If we use update command the document is updated only if that document record is present in collection. But if the requirement is that if document is present then we update it otherwise insert it as a new record. Then we can use upsert command. Suppose we run an update command as follows [crayon-5b77c5fee90b6602594589/] If