SmartCollection not displaying fields

Feature(s) impacted


Observed behavior

The route to my Smartcollection works fine but is displaying an empty list with no fields. The “Fields” tab is neither clickable when trying to edit the layout.

Expected behavior

SmartCollections displaying the expected fields.

Failure Logs

No failure logs, I’ve probably missed something else…

console log of data sent by “get” route :

type: ‘pDComment’,
id: ‘110755c2-247d-447a-90da-92471d382f09’,
attributes: {
id: ‘110755c2-247d-447a-90da-92471d382f09’,
description: "Gouverner c'est prévoir". Apparemment, nous n'avons plus de gouvernants depuis quelques décennies...,
published_at: 2022-07-24T09:50:00.000Z


  • Project name: PolitizrForest

  • Team name: Operations

  • Environment name: Development

  • Agent type & version:
    “body-parser”: “1.19.0”,
    “chalk”: “~1.1.3”,
    “cookie-parser”: “1.4.4”,
    “cors”: “2.8.5”,
    “debug”: “~4.0.1”,
    “dotenv”: “~6.1.0”,
    “express”: “~4.17.1”,
    “express-jwt”: “6.1.2”,
    “forest-cli”: “^3.0.6”,
    “forest-express-sequelize”: “^8.0.0”,
    “morgan”: “1.9.1”,
    “mysql2”: “~2.2.5”,
    “require-all”: “^3.0.0”,
    “sequelize”: “~5.15.1”

  • Recent changes made on your end if any:

I’m trying to get a single view (SQL’s “Union”) of 2 tables (p_d_d_comment + p_d_r_comment => p_d_comment).

I read the documentation to help me, but I’m not familiar with JS coding.

forest/p-d-comment.js :

const { collection } = require('forest-express-sequelize');
const models = require('../models');

// Union of pddcomment & pdrcomment collection
collection('pDComment', {
    isSearchable: true,
    fields: [{
        field: 'id',
        type: String,
    }, {
        field: 'description',
        type: String,
    }, {
        field: 'published_at',
        type: Date,

routes/p-d-comment.js :

// Grouping of pddcomment & pdrcomment collection
const { RecordSerializer } = require('forest-express-sequelize');
const express = require('express');
const router = express.Router();
const { connections } = require('../models');

const sequelize = connections.default;

router.get('/pDComment', (req, res, next) => {
  const limit = parseInt( || 20;
  const offset = (parseInt( - 1) * limit;
  const queryType = sequelize.QueryTypes.SELECT;

  const queryData = `
    SELECT d.uuid as id, d.description as description, d.published_at as published_at
    FROM p_d_d_comment as d
    SELECT r.uuid as id, r.description as description, r.published_at as published_at
    FROM p_d_r_comment as r
    ORDER BY published_at desc
    LIMIT ${limit}
    OFFSET ${offset}

  const queryCount = `
    SELECT sum(tbl.tblCount) as count
        SELECT count(*) as tblCount from p_d_d_comment
        UNION ALL
        SELECT count(*) as tblCount from p_d_r_comment
        ) tbl;

    sequelize.query(queryData, { type: queryType }),
    sequelize.query(queryCount, { type: queryType }),
    .then(async ([pDCommentsList, pDCommentsCount]) => {
      const pDCommentSerializer = new RecordSerializer({ name: 'pDComment' });
      const pDComments = await pDCommentSerializer.serialize(pDCommentsList);
      const count = pDCommentsCount[0].count;
      res.send({ ...pDComments, meta:{ count: count }});
    .catch((err) => next(err));

module.exports = router;

Hi @Lionel :wave: and welcome to our community.
I think there is an error on your console of your browser can you share it with us please.

Thanks @Arnaud_Moncel :+1:

Yes, you’re right, I forget to check the console, here is the error

companion-bubble.js:1465 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.keys ()
at companion-bubble.js:1465:19726
at ()
at Ln (companion-bubble.js:1465:19144)
chunk.675.c87c323478477298af28.js:2 Forest Admin :evergreen_tree: Start third-party services tracking.

It seems not to be related to the issue.
I’m asking something, the field type should be under quotes.

  field: 'id',
  type: String,

should be

  field: 'id',
  type: 'String',

Can you try this? :pray:

Thanks @Arnaud_Moncel , you’ve got it, it works, sorry for my mistakes. :face_with_peeking_eye:

1 Like