This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo rm /var/lib/mongodb/mongod.lock | |
sudo -u mongodb mongod -f /etc/mongodb.conf --repair | |
sudo start mongodb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.help() | |
DB methods: | |
db.addUser(username, password[, readOnly=false]) | |
db.auth(username, password) | |
db.cloneDatabase(fromhost) | |
db.commandHelp(name) returns the help for the command | |
db.copyDatabase(fromdb, todb, fromhost) | |
db.createCollection(name, { size : ..., capped : ..., max : ... } ) | |
db.currentOp() displays the current operation in the db | |
db.dropDatabase() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.users.help() | |
DBCollection help | |
db.users.find().help() - show DBCursor help | |
db.users.count() | |
db.users.dataSize() | |
db.users.distinct( key ) - eg. db.users.distinct( 'x' ) | |
db.users.drop() drop the collection | |
db.users.dropIndex(name) | |
db.users.dropIndexes() | |
db.users.ensureIndex(keypattern[,options]) - options is an object with these possible fields: name, unique, dropDups |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.system.js.save({_id:"last_n_users", value: function(n){return db.users.find().sort({created_at:-1}).limit(n).toArray()}}) | |
> db.eval("last_n_users(3)") | |
[ | |
{ | |
"_id" : ObjectId("4e8c2a00de570598c220878b"), | |
"username" : "Zoloo", | |
"created_at" : ISODate("2011-10-04T16:00:00Z"), | |
"password" : "secret", | |
"last_visited_at" : ISODate("2011-10-04T16:00:00Z") | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Өгөгдөл 1 | |
овог: Болд | |
нэр: Отгонхүү | |
хүйс: эрэгтэй | |
хаяг: БГД 2-5-4 тоот | |
# Өгөгдөл 2 | |
нэр: Номин | |
хүйс: эмэгтэй |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private native void nativeMe() | |
{ | |
// Энд доод түвшний кодоо бичээрэй. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hooks | |
unless Array::unique | |
Array::unique = -> | |
output = {} | |
output[@[key]] = @[key] for key in [0...@length] | |
value for key, value of output | |
unless Array::contains_array | |
Array::contains_array = (arr)-> | |
@.every (val)-> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Ability, ability, as_array, is_array, is_array_contains_array; | |
if (!Array.prototype.unique) { | |
Array.prototype.unique = function() { | |
var key, output, value, _i, _ref, _results; | |
output = {}; | |
for (key = _i = 0, _ref = this.length; 0 <= _ref ? _i < _ref : _i > _ref; key = 0 <= _ref ? ++_i : --_i) { | |
output[this[key]] = this[key]; | |
} | |
_results = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
За тэгвэл чадлынхаа хэрээр тайлбарлах гээд үзье: Ангилалуудаа categories гэсэн хүснэгтэнд хадгальяа, | |
тэр хүснэгт нь id, name, ancestry гэсэн талбаруудтай. | |
Хамгийн эхний өгөгдөл буюу A-г хийхэд дараах байдалтай болно. | |
id|name|ancestry | |
1|A|null | |
Өөрөөр хэлбэл A нь root болно. Одоо B-г нэмвэл: | |
id|name|ancestry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# This file is auto-generated from the current state of the database. Instead | |
# of editing this file, please use the migrations feature of Active Record to | |
# incrementally modify your database, and then regenerate this schema definition. | |
# | |
# Note that this schema.rb definition is the authoritative source for your | |
# database schema. If you need to create the application database on another | |
# system, you should be using db:schema:load, not running all the migrations | |
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | |
# you'll amass, the slower it'll run and the greater likelihood for issues). |