mongoDB Miscellaneous

  1. Password Change: db.changeUserPassword ( 'tank2', 'test');

     

  2.  Here I encountered a problem: 
        the mongod : error the while loading the Libraries Shared: libcurl.so.4: CAN not Open Shared Object  File : No SUCH File or Directory 
      so install curl 
        root @ Debian : / Home / csr # APT-GET install curl

     

  3. monDB time format handling    new new MongoDB \ the BSON \ UTCDateTime (createFromFormat :: Carbon ( 'Ymd H: I: S', '2018-06-15 12:12:12') -> for EndOfDay ());
     / * return mongoDB type time * / 
    function mongoDate ( $ DATE ) {
        return  new new MongoDB \ the BSON \ UTCDateTime ( $ DATE ); 
    } 
    Composer loading mongodb in mongodb add the statement "jenssegers / mongodb" .json in: "to 3.2"

     

  4. mongDB data: data packets - Collection - Documents

     

  5. Concept of a cursor
     var . Aa = DB set name. Find (); 
    when the output aa, when this output, aa no value of the 
    order is a numerical aa one one output, a circular manner can be used (can here understood to cursor), or may be understood as a query constructor (the first query to check the data, and the time required to call) 
    AA . forEach (X) {
     print_r (X. elements) 
    }

     

  6. Performance Analysis 
    Performance Analysis function (EXPLAIN) 
    DB use . Collectionname .find ({condition}). Explain ()

     

  7. Index 
    db collection name .ensureIndex. ({ "Key": 1}) using the index on ensureIndex established name. "1": indicates ascending order name, "- 1 ": indicates descending order name. 
    Unique index only take effect when the set is empty, if data exists, will not be effective 
    db collection name .ensureIndex. ({ 'Key':. 1}, { 'UNIQUE': to true }) 
    joint index 
    db . .EnsureIndex set name ({ 'key1':. 1, 'key2':. 1 }) 
    DB collection name .ensureIndex. ({ 'key2':. 1, 'key1':. 1 }) 
    after the establishment of the above two indexes, the system will automatically search time wherein a select 
    if you want to perform the specified one of the following ways 
    db collectionname .find ({ 'key1': ' value1', 'key2': 'value2'}).. hint ({ 'key1': 1, 'key2':. 1 }) 
    specified index db collection name .dropIndexes ( "getIndexes the name").

Guess you like

Origin www.cnblogs.com/phpk/p/10939247.html