как изменить формат объекта в строке с помощью feathersJs с помощью мангуста после заполнения

#node.js #mongoose #feathersjs

Вопрос:

это источник кода (nameOfService.hooks.js) я использую feathersJS-заполняю мангустом у меня есть 4 службы (устройство,местоположение,узел,переменные) я хочу заполнить данные из службы определения местоположения в службу устройств с помощью выбора («имя») местоположения и вернуть результат в строке типа не объект

 const { populate } = require('feathers-hooks-common');
const schema = {
  service: 'device',
  include: [
    {
    service: 'location',
    nameAs: 'location',
    parentField: 'idLocation',
    childField: '_id',
    query: {
      $select: 'name',
    }
  },
    {
      service: 'variables',
      nameAs: 'variables',
      parentField: 'variables',
      childField: '_id',
      query: {
        $select: { 'createdAt':0,'updatedAt':0,'__v':0},
        $sort: {createdAt: -1}
      }},
      {
        service: 'node',
        nameAs: 'node',
        parentField: 'idNode',
        childField: '_id',
        query: {
          //$limit: 5,
          $select: {'name':1, '_id':0},
          $sort: {createdAt: -1}
        }
  }
    ],
  }
module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: populate({ schema, profile: true }),
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
};
 

это результат работы почтальона :

  {
        "variables": [
            {
                "_id": "60b5acd7ed6f40270154c66e",
                "name": "Hz",
                "unit": "Hz",
                "vector": "frequence",
                "plotType": "line"
            },
            {
                "_id": "60b5ac89ed6f40270154c66d",
                "name": "Hz",
                "unit": "Hz",
                "vector": "frequence",
                "plotType": "line"
            }
        ],
         id: 1,
        icon: "power",
        name: "Compteur COurant",
        layer: "ELECTRICITE",
        "enabled": false,
        "down": false,
        "idNode": "60b4510676350d2445c6bbb0",
        "error": true,
        "idLocation": "60acd2bdd95bb81b2a01e28f",
       derniere_insertion: "2021-05-04",
        "description": "warning",
        "createdAt": "2021-06-01T23:33:02.985Z",
        "updatedAt": "2021-06-01T23:33:02.985Z",
        "__v": 0,
        "_include": [
            "location",
            "variables",
            "node"
        ],
        "_elapsed": {
            "location": 145751727,
            "variables": 244399962,
            "node": 301941006,
            "total": 302752718
        },
        "location": {
            "_id": "60acd2bdd95bb81b2a01e28f",
            "name": "usine bloc A"
        },
        "node": {
            "name": "node1"
        }
    }
         

 
 

this is the result i want :

      {
        id: 1,
        icon: "power",
        name: "Compteur COurant",
        layer: "ELECTRICITE",
        enabled: false,
        down: true,
        node: "Node 1",
        error: false,
        location: "Usine Bloc A",
        derniere_insertion: "2021-05-04",
        description: "warning",
        variables: [
              {
                "_id": "60b5ac89ed6f40270154c66d",
                "name": "Hz",
                "unit": "Hz",
                "vector": "frequence",
                "plotType": "line"
            },
            {
                "_id": "60b5ac89ed6f40270154c66d",
                "name": "Hz",
                "unit": "Hz",
                "vector": "frequence",
                "plotType": "line"
            }

}