được rồi. chạy thêm dòng
db.adminCommand({setFeatureCompatibilityVersion: "3.6"})
trên server là chạy bình thường
được rồi. chạy thêm dòng
db.adminCommand({setFeatureCompatibilityVersion: "3.6"})
trên server là chạy bình thường
@Vụ-Chu ko mình update toàn dùng _id. Dùng id để xác định document rồi mới update
@Anh-Thi bạn tự học mà xây dựng được thế này là quá giỏi rồi
@Minh-Sang xem log newuser thế nào
Mình đang truy suất 1 bảng comment trong đó có comment_cha sẽ được lòng các comment_con vào thông qua _id nhưng mình không biết cách limit số lượng con. Mong mấy bạn giúp hoặc gốp ý cách nào tối ưu hơn.
exports.loadComments = function (req, res) {
var slug = req.query.slug;
if(!slug) return res.json({error: "Không lấy được slug bài viết"});
var trang = req.query.page ? req.query.page : 1;
var limit = config.limit;
var skip = (trang - 1) * limit;
var tempArray = [];
commentsModel.aggregate([
{$project: {_id: 1, user_ObjectId: 1, comment_ObjectId: 1, commentContent: 1, commentModify: 1, post_slug: 1, point: {$subtract: ['$commentUpVote','$commentDownVote']}}},
{$match : { post_slug : slug, comment_ObjectId: null } },
{$sort : { point : -1, commentModify: -1 } },
{
$lookup:
{
from: "users",
localField: "user_ObjectId",
foreignField: "_id",
as: "user"
}
},
{
$graphLookup: { //Chổ này là nó truy xuất lòng nhau mà không biết phải thêm chữ gì vô cho nó limit lại đã thử thêm $limit nhưng lỗi
from: "comments",
startWith: "$_id",
connectFromField: "_id",
connectToField: "comment_ObjectId",
as: "Comments_child"
}
},
{ $skip: skip },
{ $limit: 2 }
], function (err, result) {
if (err) {
console.log(err);
res.json({'error': 'Không kết nối được máy chủ! F5 thử lại'})
} else {
var data = ({page: parseInt(trang) + 1, comments: result})
return res.json(data);
}
}).allowDiskUse(true);
}
//dữ liệu trã về
{
"page": 2,
"comments": [
{
"_id": "5b24bc26e281911588e79b9a",
"comment_ObjectId": null,
"commentContent": "9",
"post_slug": "0Pxzb9f",
"user_ObjectId": "5b1f417ba5290e11d4c39f1f",
"commentModify": "2018-06-16T07:28:38.442Z",
"t": null,
"point": 0,
"user": [
{
"_id": "5b1f417ba5290e11d4c39f1f",
"quyen_hang": 3,
"ten_dang_nhap": "1633029573462982",
"mat_khau": "$2b$10$i5KY9I.C.mES4vtoRXri2exzKoy97L6jsop7LKm02ktRK/QyKVzRi",
"email": "[email protected]",
"anh_dai_dien": "images/avatar/1633029573462982.jpg",
"ten": "Kha Pham",
"mang_xa_hoi": {
"facebook": [
{
"id": "1633029573462982"
}
]
},
"__v": 0
}
],
"Comments_child": [ // có cách nào để limit cái này theo ý mình không
{
"_id": "5b24bc1de281911588e79b94",
"commentUpVote": 0,
"commentDownVote": 0,
"comment_ObjectId": "5b24bc26e281911588e79b9a",
"commentContent": "3",
"commentStatus": 1,
"commentImage": {
"type": null,
"url": null,
"video": null
},
"post_slug": "0Pxzb9f",
"user_ObjectId": "5b1f417ba5290e11d4c39f1f",
"commentCreate": "2018-06-16T07:28:29.531Z",
"commentModify": "2018-06-16T07:28:29.531Z",
"__v": 0
},
{
"_id": "5b24bc1ce281911588e79b93",
"commentUpVote": 0,
"commentDownVote": 0,
"comment_ObjectId": "5b24bc26e281911588e79b9a",
"commentContent": "2",
"commentStatus": 1,
"commentImage": {
"type": null,
"url": null,
"video": null
},
"post_slug": "0Pxzb9f",
"user_ObjectId": "5b1f417ba5290e11d4c39f1f",
"commentCreate": "2018-06-16T07:28:28.447Z",
"commentModify": "2018-06-16T07:28:28.447Z",
"__v": 0
},
{
"_id": "5b24bc1be281911588e79b92",
"commentUpVote": 0,
"commentDownVote": 0,
"comment_ObjectId": "5b24bc26e281911588e79b9a",
"commentContent": "1",
"commentStatus": 1,
"commentImage": {
"type": null,
"url": null,
"video": null
},
"post_slug": "0Pxzb9f",
"user_ObjectId": "5b1f417ba5290e11d4c39f1f",
"commentCreate": "2018-06-16T07:28:27.461Z",
"commentModify": "2018-06-16T07:28:27.461Z",
"__v": 0
}
]
},
{
"_id": "5b24bc25e281911588e79b99",
"comment_ObjectId": null,
"commentContent": "8",
"post_slug": "0Pxzb9f",
"user_ObjectId": "5b1f417ba5290e11d4c39f1f",
"commentModify": "2018-06-16T07:28:37.442Z",
"t": null,
"point": 0,
"user": [
{
"_id": "5b1f417ba5290e11d4c39f1f",
"quyen_hang": 3,
"ten_dang_nhap": "1633029573462982",
"mat_khau": "$2b$10$i5KY9I.C.mES4vtoRXri2exzKoy97L6jsop7LKm02ktRK/QyKVzRi",
"email": "[email protected]",
"anh_dai_dien": "images/avatar/1633029573462982.jpg",
"ten": "Kha Pham",
"mang_xa_hoi": {
"facebook": [
{
"id": "1633029573462982"
}
]
},
"__v": 0
}
],
"Comments_child": []
}
]
}
graphLookup document
https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/index.html#examples
@Vũ Big thank. đã làm được khi cài https://github.com/wrakky/react-html-parser thêm vào
Bạn cần phải xác thực ứng dụng, rồi quay clip cách hoạt động của những gì bạn lấy nữa
@Bảo free hết nha bạn
Mình chưa tìm hiểu nodebb nhưng đã là node thì chắc chắn sẽ giống nhau thôi. Còn phần backup/restore nếu là csdl thì viết bằng gì củng được mà nên chọn thư viện có sẳn cho tiện.
Tùy nhà bạn. Bạn có thể bắt đầu trực tiếp luôn củng được nếu bạn đã có kiến thức về lặp trình
Về hương học thì mình học theo
Được thì tìm hiểu luôn MERN nữa là ngon
Cuối cùng http://online.khoapham.vn/9-react-native
@Anh-Thi phần karaoke xử lý sao vậy bác
@CodeConCat thấy là không muốn đọc rồi haha
Mình tìm được bài viết rồi. Do server và client của mình chạy khác port nên dùng HashRouter để tránh gửi request lên server khi deloy thì chuyển về như củ là được.
mình muốn bỏ /#/ ra khỏi url mà không biết cách nào. khi không sử dụng HashRouter mà dùng Router thì nó bị lỗi không get được url
import { BrowserRouter as Router, Route, Link, withRouter, HashRouter } from "react-router-dom";
ReactDOM.render(
<Provider store={store} >
<HashRouter>
<div>
<Nav />
<Route exact path="/" component={HomePage} />
<Route path="/v/:slug" component={ViewPage} />
<Route path="/login" component={LoginPage} />
<Route path="/new" component={HomePage} />
<Route path="/fetch9Gag" component={fetch9Gag} />
<Route path="/fetchHaiVN" component={fetchHaiVN} />
<Route path="/fetchXemVN" component={fetchXemVN} />
<Route path="/profile" component={ProfilePage} />
<Route path="/c/:slug" component={HomePage} />
</div>
</HashRouter>
</Provider>
,
document.getElementById('root')
);
@Thành187 bạn dùng axios + proxy
Thường thì dùng 1 proxy đến khi nó block rồi chuyển sang 1 proxy khác.
Proxy có thể tìm trên google với cú pháp free proxy
Theo mình nghĩ thì là lưu ở session rồi check ở session ngôn ngữ gì thì làm.
được rồi. chạy thêm dòng
db.adminCommand({setFeatureCompatibilityVersion: "3.6"})
trên server là chạy bình thường
@CodeConCat
Trong doc
db.runCommand({
update: "students2",
updates: [
{ q: { }, u: { $set: { "grades.$[elem].mean" : 100 } }, arrayFilters: [ { "elem.grade": { $gte: 85 } } ], multi: true }
]
})
code của mình
usersModel.findByIdAndUpdate(req.session.passport.user, {
$set: {
'thongBao.$[i].trangThaiThongBao': 2
}
}, {
"arrayFilters": [{
"i._id": idNguoiDangNhap
}]
}