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
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
// 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
{ | |
"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
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
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' : '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
model | |
--user.model.js // model User sử dụng để query với mongoose | |
--init.js // Khởi tạo một số dữ liệu user để tiện cho export data | |
public | |
exports | |
--file_excel_export.xlsx // lưu trữ file excel được export | |
view | |
--index.ejs // Trang chủ | |
--receive.ejs // Trang nhận liên kết link download từ server gửi về và hiển thị lên | |
-app.js // cấu hình ứng dụng |
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
{ | |
"name": "excel_node_sample", | |
"version": "0.0.0", | |
"private": true, | |
"scripts": { | |
"start": "node ./bin/www" | |
}, | |
"dependencies": { | |
"ejs": "^2.5.6", | |
"express": "^4.15.3", |
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
let express = require('express'); | |
let router = express.Router(); | |
let nodeXlsx = require('node-xlsx'); | |
let User = require('./model/user.model'); | |
let fs = require('fs'); | |
/* GET home page. */ | |
router.get('/', function (req, res) { | |
res.render('index', {title: 'Express'}); | |
}); |