Skip to main content

Posts

MongoDB - How to reduce storage size after deleting documents on replica set?

MongoDB does not free the disk space for OS use after deleting bunch of documents from the collection. We can reclaim that space using following cases. By using compact command - Can be run on collections, but block all orations on database, need small downtime By using repaireDatabase - Run on database need extra space and serious downtime By dumping database and than drop and restore it - Time consuming and need downtime By copy database using temporary name drop original and then re copy with original name - Time consuming and need downtime Following is the best method of achieve same without downtime on replica set Step down secondary server Delete database files Start server, It will start Replica Set Initial Sync. After sync over do the same with other secondary servers one by one For primary server step it down. Make sure one of the secondary become primary Delete database file on primary Start primary server It will start Replica Set Initial Sync. After R
Recent posts

MongoDB Exact Word Search Without $text

We can use simple $regex to find out documents with specific field have exact word in string value For Example Let's say we have following documents in collection sampledata {      _id : ObjectId("583bbccc592818101fb7f3f8"),    "textdata" : "This is sample text data", }, {      _id : ObjectId("583bbccc592818101fb7e43w"),    "textdata" : "data use by default", }, {      _id : ObjectId("583bbccc592818101fb723ed"),    "textdata" : "bird can fly, This is not always true", } 1 - Now we want only document which have "textdata" contains word "data" db.sampledata.find({ "textdata" : { $regex : /\bdata\b/ }) Above query will return following documents {      _id : ObjectId("583bbccc592818101fb7f3f8"),    "textdata" : "This is sample text data", }, {      _id : ObjectId("583bbccc592818101fb7e43w"),    &

FULL OUTER JOIN into the SQL Server query

Full outer join is use full when we need following kind of result from tow individual queries Result 1 IdColumn Data1 1 Hello1 2 Hello2 . . . . 10 Hello10 Result 2 IdColumn Data2 1 Hi1 2 Hi2 . . . . 10 Hi10 Final Result = Result 1 + Result 2 IdColumn Data1 Data2 1 Hello1 Hi1 2 Hello2 Hi2 . . . . . . 10 Hello10 Hi10 {{ For Example }} select  isnull (A.Id,B.Id) as Id , A.*, B.* from ( select IdColumn as Id,* from xyz ) A full  outer join ( select IdColumn as Id,* from abc ) B on  A.Id = B.Id {{ NOTE }} You have to care about null in the result set when there are no data in either table for the respected IDs.

Single Quote (') into the data control bind system <%# %>

Here is Tips to put single quote ( ' ) into the data bind control binding syntax that is <%# ... %> For Example: OnClientClick = <% # "xyz('" + Eval("DataColumn").ToString() "'); return false;" %> Direct put the binder syntax after = of the property you want to bind, don't use single or double quote.  And put any string constant before and after your Eval(""). It is use full when we want to call javascript function on the click event of link,button,image etc controls.

SqlConnection from ObjectContext.Connection

Following is C# code to get the  SqlConnection from ObjectContext.Connection . This is usefully to run dynamically created query using ADO.NET using connection string specified into the EDMX ObjectContext object. C# Code Example : using ( EntityContext context = new EntityContext ()) { EntityConnection ec = ( EntityConnection )context.Connection; SqlConnection sc = ( SqlConnection )ec.StoreConnection; SqlDataAdapter da = new SqlDataAdapter (strQuery, sc); DataSet ds = new DataSet (); da.Fill(ds); return ds.Tables[0]; }

Set focus on selection of date from jQuery datepicker to control it self

Following is the jQuery code to set focus on control after selecting the date from the jQuery Date Picker jQuery.extend(jQuery.datepicker, { afterShow: function (event) {     jQuery.datepicker._getInst(event.target).dpDiv.css('z-index', 99999999); } }); jQuery(function(){     $("#divGameQuestionPanel [datepicker]").datepicker({         changeMonth: true,         changeYear: true,         yearRange: 'c-99:c+0',         showOn: "button",         buttonImage: calImageSrc,         buttonImageOnly: true,         dateFormat: 'dd/mm/yy',         onSelect: function (dateText, inst) { $(this).focus(); }     }).focus(function (event) {         jQuery.datepicker.afterShow(event);     }); });

Developer must have Browser Addons list

Google Chrom 1) Chrome - use full to select color and its different sades https://chrome.google.com/webstore/detail/gefgglgjdlddcpcapigheknbacbmmggp Live website to use it without add into the browser http://lucumalabs.com/chroma