首页 \ 问答 \ Node.js Mongoskin集合迭代> Jade(Node.js Mongoskin collection iteration > Jade)

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

原文:
更新时间:2022-05-02 09:05

最满意答案

帮助文件中写的内容:

应合并两个树形图的高度高度。 如果未指定(或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.

相关问答

更多
  • jlhoward和Backlin的答案都很好。 你也可以尝试使用dendextend包,这是为这类事情设计的。 它有一个像rect.hclust一样工作的rect.dendrogram函数,但是有一个rect.hclust参数(加上对rect边缘位置的更多控制)。 为了找到相关的高度,你可以使用heights_per_k.dendrogram函数(在使用dendextendRcpp包的时候速度要快得多) 下面是一个简单的例子,说明如何获得与上述例子相同的结果(带有彩色分支的额外奖励,仅仅为了好玩): ins ...
  • (如果拼写正确,可能会有所帮助。) A2R是一个源包。 因此,您可能需要使用系统工具链进行编译。 如果您使用的是Linux,那么这些通常位于您的系统中,但如果您使用的是Mac(就像我一样)或Windows上,则不会。 该软件包可以在Mac上从源代码编译。 编译过程可能不需要工具链。 所以试试这个: install.packages(" A2R_0.0-4.tar.gz", type ="source") 还有一些其他的依赖:'trimcluster','prabclus','MASS' ...
  • 你可以使用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 ...
  • 编辑数据,添加一个加倍的列和一个单一的。 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 ...
  • 尝试这个: 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并 ...
  • 我认为这应该有效: 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'))
  • Merge-sort的理念是将较小细分的结果合并为较大的细分。 在merge-sort中,首先将2个元素(1个元素的2个数组)合并为2个元素的排序数组,然后将2个元素的2个排序数组合并为4个元素的排序数组(因为2个数组已排序,只需要遍历和比较,较小的元素总是以升序排列在两个数组中,然后将2个排序的4个元素数组合并为8个元素的排序数组。 | | | | | | | | | |sorted | | | | |sorted | ...
  • 帮助文件中写的内容: 应合并两个树形图的高度高度。 如果未指定(或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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)