Node.js Mongoskin集合迭代> Jade(Node.js Mongoskin collection iteration > Jade)
我试图通过一个集合来迭代创建一个目录并通过jade向用户显示它,但tableContent每次运行时都是'No Orders',即使很难,我认为我已正确设置了db。
“listing.js”用于迭代db集合并将其发送给jade
var express = require('express'); var router = express.Router(); var mongo = require('mongoskin'); var db = mongo.db("mongodb://localhost:27017/db", {native_parser:true}); var iterateOrders = function() { var tableContent = ''; //TableContent Array db.collection('orders').find({}, function(err, result) { result.each(function(err, order) { tableContent += '<tr>'; tableContent += '<td>' + this.orderID + '</td>'; tableContent += '<td>' + this.receiverName + '</td>'; tableContent += '<td>' + this.receiverAddress + '</td>'; tableContent += '<td>' + this.receiverEmail + '</td>'; tableContent += '<td>' + this.order + '</td>'; tableContent += '</tr>'; }); }); if (tableContent === '') {tableContent = 'No Orders';} return tableContent; } router.get('/', function(req, res) { res.render('listing', { title: 'Orderlist:', table: iterateOrders() }); }); module.exports = router;
我已经使用“mongo”手动写入数据库
db.orders.insert({ '的orderID' ......恩'})
我的玉器实现是
block content table thead th # th Name th Addr th Email th Order tbody= table
I'm trying to iterate trough a collection to create a table of contents and show it to user trough jade, yet tableContent is 'No Orders' every time I run, even tough I think I have set the db correctly.
"listing.js" for iterating the db collection and sending it off to jade
var express = require('express'); var router = express.Router(); var mongo = require('mongoskin'); var db = mongo.db("mongodb://localhost:27017/db", {native_parser:true}); var iterateOrders = function() { var tableContent = ''; //TableContent Array db.collection('orders').find({}, function(err, result) { result.each(function(err, order) { tableContent += '<tr>'; tableContent += '<td>' + this.orderID + '</td>'; tableContent += '<td>' + this.receiverName + '</td>'; tableContent += '<td>' + this.receiverAddress + '</td>'; tableContent += '<td>' + this.receiverEmail + '</td>'; tableContent += '<td>' + this.order + '</td>'; tableContent += '</tr>'; }); }); if (tableContent === '') {tableContent = 'No Orders';} return tableContent; } router.get('/', function(req, res) { res.render('listing', { title: 'Orderlist:', table: iterateOrders() }); }); module.exports = router;
I have written to the database manually using "mongo"
db.orders.insert({'orderID'...en'})
My jade implementation is
block content table thead th # th Name th Addr th Email th Order tbody= table
原文:
最满意答案
帮助文件中写的内容:
应合并两个树形图的高度高度。 如果未指定(或NULL),则默认值比两个组件高度(大于)大10%。
What is written in the help file:
height height at which the two dendrograms should be merged. If not specified (or NULL), the default is ten percent larger than the (larger of the) two component heights.
相关问答
更多-
R中水平树状图的树状切割和簇周围的矩形(Tree cut and Rectangles around clusters for a horizontal dendrogram in R)[2023-10-04]
jlhoward和Backlin的答案都很好。 你也可以尝试使用dendextend包,这是为这类事情设计的。 它有一个像rect.hclust一样工作的rect.dendrogram函数,但是有一个rect.hclust参数(加上对rect边缘位置的更多控制)。 为了找到相关的高度,你可以使用heights_per_k.dendrogram函数(在使用dendextendRcpp包的时候速度要快得多) 下面是一个简单的例子,说明如何获得与上述例子相同的结果(带有彩色分支的额外奖励,仅仅为了好玩): ins ... -
R彩色树状图建议?(R Colored dendrogram suggestions?)[2021-12-15]
(如果拼写正确,可能会有所帮助。) A2R是一个源包。 因此,您可能需要使用系统工具链进行编译。 如果您使用的是Linux,那么这些通常位于您的系统中,但如果您使用的是Mac(就像我一样)或Windows上,则不会。 该软件包可以在Mac上从源代码编译。 编译过程可能不需要工具链。 所以试试这个: install.packages("A2R_0.0-4.tar.gz", type ="source") 还有一些其他的依赖:'trimcluster','prabclus','MASS' ... -
R - if-else应用于列表(R - if-else applied to a list)[2022-09-17]
你可以使用lapply和transform / within 。 有三种可能性: a) ifelse lapply(myfiles, transform, V3 = ifelse(V2 > 50, V3, NA)) b)数学运算符(可能更有效) lapply(myfiles, transform, V3 = NA ^ (V2 <= 50) * V3) c) is.na<- lapply(myfiles, within, is.na(V3) <- V2 < 50) 结果 [[1]] V1 V2 ... -
R中合并的后缀(Suffixes in merge in R)[2023-03-27]
编辑数据,添加一个加倍的列和一个单一的。 x=data.frame(Date= as.Date(c("2015-05-31","2015-06-30","2015-07-31")), AAPL=c(100,200,150), v2=1:3, v3=1:3) y=data.frame(Date=as.Date(c("2015-05-31","2015-06-30","2015-07-31")), AAPL ... -
GraphViz的 GraphViz
-
合并R中的几个数据帧(Merge several dataframes in R)[2023-02-15]
尝试这个: lst <- list(dfB, dfC, dfD) result <- dfA for (df in lst) result <- merge(result,df,by="ID") Try this: lst <- list(dfB, dfC, dfD) result <- dfA for (df in lst) result <- merge(result,df,by="ID") -
在git log ,我看到一个开发人员做了“合并远程跟踪分支'origin / master'”这可能是什么原因? 是的,这是原因,你的git pull origin master将: 获取origin/master的内容(已包含与origin/development的合并) 将其与您的本地主分支合并(快进合并) 考虑到已经克隆了origin/master ,我不建议在此时改变它的历史。 所以没有' git reset '。 如果您需要在合并之前继续使用master,只需从git log获取正确的SHA1并 ...
-
R中的合并命令(Merge Command in R)[2022-04-04]
我认为这应该有效: merged.df <- merge(data1, data2, by='NAME', suffixes=c('.fileA', '.fileB')) I think this should work: merged.df <- merge(data1, data2, by='NAME', suffixes=c('.fileA', '.fileB')) -
应用合并排序逻辑(applied merge sort logic)[2022-03-15]
Merge-sort的理念是将较小细分的结果合并为较大的细分。 在merge-sort中,首先将2个元素(1个元素的2个数组)合并为2个元素的排序数组,然后将2个元素的2个排序数组合并为4个元素的排序数组(因为2个数组已排序,只需要遍历和比较,较小的元素总是以升序排列在两个数组中,然后将2个排序的4个元素数组合并为8个元素的排序数组。 | | | | | | | | | |sorted | | | | |sorted | ... -
当应用于R中的树状图时,`merge`实际上做了什么?(What does `merge` actually do when applied to dendrograms in R?)[2024-02-23]
帮助文件中写的内容: 应合并两个树形图的高度高度。 如果未指定(或NULL),则默认值比两个组件高度(大于)大10%。 What is written in the help file: height height at which the two dendrograms should be merged. If not specified (or NULL), the default is ten percent larger than the (larger of the) two component ...