meteor-tabular
meteor-tabular copied to clipboard
Use "mongo lookup" of "view" with Tabular
I try to create view with lookup relation, and then use it in meteor-tabular.
db.createView (
"orderView",
"order",
[
{
$lookup: {
from: "customer",
localField: "customerId",
foreignField: "_id",
as: "customerDoc"
}
},
{
$unwind: "$customerDoc"
}
]
)
let OrderView = new Mongo.Collection('orderView');
...
name : 'order',
collection : OrderView,
columns : [
{data: "_id", title: "ID"},
{
data: "orderDate",
title: "Date",
render: function (val, type, doc) {
return moment(val).format('DD/MM/YYYY');
}
},
{data: "total", title: "Total"},
{data: "des", title: "Description"},
{data: "customerDoc.name", title: "Name"},
],
it work fine, but it is slow to react (real time).