2018-02-18

MongoDB - Query string match in a "like" manner

db.collection_name( { field_name: /search_string/ } );

2018-02-10

MongoDB - Resolve server startup issues

mongod --repair --dbpath /PATH_TO_DB


This resolved this error message:
"Assertion failure isOk() src/mongo/db/storage/mmap_v1/extent.h 81"

MacOS - Get file or folder absolute path copied to the clipboard

(1) Select a file or folder using Finder
(2) Press COMMAND + OPTION + C

2018-02-07

MongoDB - Upgrade standalone from v3.4 to v3.6


// Set the feature compatibility version to 3.4
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } );
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

// Test and let your application season for a while

// Once convinced everything works, then set features compatibility version to 3.6
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )

2018-01-06

MongoDB - Aggregation, simple group by single field with frequency count

db.[COLLECTION_NAME].aggregate([
    {"$group" : {_id:"$FIELD_TO_GROUP_BY", count:{$sum:1}}}
])

2017-11-08

MySQL - Select date with microseconds precision

SELECT DATE_FORMAT( CURRENT_TIMESTAMP, "%W %M %e %Y %f");
SELECT now(6);
SELECT MICROSECOND(now(6));