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
use admin | |
var role = { | |
'role' : 'promaster', | |
'privileges' : [ | |
{ | |
'resource': {'db' : 'company', 'collection' : 'users'}, | |
'actions': ['find'] | |
}, | |
{ | |
'resource': {'db' : 'demo', 'collection' : 'chat'}, |
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
use phone_solution | |
db.people.insert({'name': 'ThuyNgan', 'age': 24}); | |
db.people.insert({'name': 'NguyenManh', 'age': 24}); | |
db.work.insert({'title': 'Travel agent', 'location': 'HaNoi'}); | |
db.work.insert({'title': 'It Develop', 'location': 'HaNoi'}); | |
use company | |
db.users.insert({'name': 'admin_company', address: 'GiaLam'}); | |
db.users.insert({'name': 'employee', address: 'VietNam'}); |
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
use admin | |
var role = { | |
'role' : 'develop', | |
'privileges' : [ | |
{ | |
'resource': {'db' : 'company', 'collection' : 'users'}, | |
'actions': ['find'] | |
} | |
], | |
'roles' : [ |
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
{ | |
"item": "Value item", | |
"alert":"Thanh Le has new message from NguyenManh!", | |
"title":"Notify vmodev platform", | |
"message":"That ko thể tin nổi" | |
} |
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
// Vooc vạch đôi chút về các cách khai báo key trong JS nào :D | |
// ----------------------^_^---------------------------------- | |
// Xem 2 cách khai báo đối tượng theo 2 cách | |
var person = { 'firstName': 'Nguyen', 'lastName': 'Manh' } | |
var person = { firstName: 'Nguyen', lastName: 'Manh' }; | |
// => 2 cách khai báo trên là giống nhau nhưng với cách 1 có ưu điêm hơn cách 2 khi có thể khai báo | |
// thuộc tính có dấu cách. Chẳng hạn tôi thêm 1 thành phần city-address vào đối tượng như sau | |
var person = { | |
'firstName': 'Nguyen', | |
'lastName': 'Manh', |
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
function Student() {} | |
Student.prototype.firstName = "Manh"; Student.prototype.lastName = "Nguyen"; | |
Student.prototype.showName = function () { | |
console.log("I'm " + this.firstName + '- ' + this.lastName); | |
}; | |
var student = new Student(); | |
console.log('Test Protoype'); console.log(student.firstName);// Manhstudent.showName(); //I'm Manh- Nguyen |
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
function Person(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.showName = function () { | |
console.log(this.firstName + '- ' + this.lastName); | |
} | |
} | |
var psn1 = new Person('manh', 'nguyen'); | |
psn1.showName(); // I'm manh- nguyen |
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 psn = new Object(); // hoặc var psn = {}; | |
psn.firstName = 'Nguyen'; | |
psn.lastName = 'Manh'; | |
psn.showName = function () { | |
console.log(this.firstName + ', ' + this.lastName); | |
} |
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 person = { | |
firstName: 'Nguyen', | |
lastName: 'Manh', | |
50: 'professional', | |
showName: function () { | |
console.log(this.firstName + ', ' + this.lastName); | |
} | |
}; |
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
// object person | |
var person = { | |
firstName: 'Nguyen', | |
lastName: 'Manh', | |
50: 'professional', | |
showName: function () { | |
console.log(this.firstName + ', ' + this.lastName); | |
} | |
}; |