meteor-tabular icon indicating copy to clipboard operation
meteor-tabular copied to clipboard

Use "mongo lookup" of "view" with Tabular

Open thearabbit opened this issue 8 years ago • 0 comments

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).

thearabbit avatar Jan 11 '17 04:01 thearabbit