2016-06-22

MongoDB - String search (similar to SQL's "like")

// Exact match
db.COLLECTION_NAME.find({ "textos.g" : "A phrase" });

// Case sensitive
db.COLLECTION_NAME.find({ "textos.g" : /.*god.*/ });
db.COLLECTION_NAME.find({ "textos.g" : /.*God.*/ });

// Case insensitive
db.COLLECTION_NAME.find({ "textos.g" : /.*god.*/i });

// Starts with
db.COLLECTION_NAME.find({ "textos.g" : /^g/i });

2016-06-16

MongoDB - How to shudown mongo?

Open terminal, and a new mongo session.

mongo
use admin
db.shutdownServer()


2016-03-24

Meteor - How to make server-side comments on HTML files (spacebars comments)

{{! This is a comment on your source code, that won't be displayed to the client }}

2016-03-17

Meteor - How to supress invalid characters entered in a textbox (Meteor event/jQuery)

"keyup .CLASS_OR_JQUERY_SELECTOR": function( evt ){

  evt.currentTarget.value =
    evt.currentTarget.value.replace(
      /[^a-zA-Z0-9]/g      , function(str) {
        console.log( 'Illegal character typed: [" ' + str + '].' );        return '';      }//function    )//replace  ;//value
}//keyup

2016-03-14

jQuery - How to filter an array of json objects

$.grep(
    ARRAY_OF_OBJECTS
    , function(obj) {
        return(
            obj.OBJECT_KEY_1 === SOUGHT_VALUE_1
            && obj.OBJECT_KEY_2 === SOUGHT_VALUE_2
        );
    }
).length;

PS. Add the .length property call if you just want to know how many sub-objects matched your query.

MongoDB - How to shutdown the server using a query statement

mongo
use admin
db.shutdownServer()

2016-03-13

Meteor - Path to the MongoDB executable in OSX

/Users/USER_NAME_HERE/.meteor/packages/meteor-tool/.1.1.10.1b51q9m++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/mongodb/bin/mongo

PS. This will of course depend on your version of Meteor (1.2.1 in this case) and OSX (10.11 in this case).