Skip to content
This repository was archived by the owner on Apr 18, 2020. It is now read-only.
This repository was archived by the owner on Apr 18, 2020. It is now read-only.

Error: column "createdat" does not exist #18

@cdm6a

Description

@cdm6a

I'm attempting to use a the following model but when I attempt to perform a 'GET' (Find all instances of the model matched by filter from the data source) I get the following response:

{
"error": {
"name": "error",
"status": 500,
"message": "column \"createdat\" does not exist",
"length": 103,
"severity": "ERROR",
"code": "42703",
"position": "101",
"file": "parse_relation.c",
"line": "2655",
"routine": "errorMissingColumn",
"stack": "error: column \"createdat\" does not exist\n    at Connection.parseE (/Users/conner/workspace/cdmcnamara/gatewayd-basic/node_modules/loopback-connector-postgresql/node_modules/pg.js/lib/connection.js:534:11)\n    at Connection.parseMessage (/Users/conner/workspace/cdmcnamara/gatewayd-basic/node_modules/loopback-connector-postgresql/node_modules/pg.js/lib/connection.js:361:17)\n    at Socket.<anonymous> (/Users/conner/workspace/cdmcnamara/gatewayd-basic/node_modules/loopback-connector-postgresql/node_modules/pg.js/lib/connection.js:105:22)\n    at Socket.emit (events.js:95:17)\n    at Socket.<anonymous> (_stream_readable.js:764:14)\n    at Socket.emit (events.js:92:17)\n    at emitReadable_ (_stream_readable.js:426:10)\n    at emitReadable (_stream_readable.js:422:5)\n    at readableAddChunk (_stream_readable.js:165:9)\n    at Socket.Readable.push (_stream_readable.js:127:10)"
}
}

My model is as follows:

{
   "name":"Addresses",
   "options":{
      "idInjection":false,
      "postgresql":{
         "schema":"public",
         "table":"addresses"
      }
   },
   "properties":{
      "id":{
         "type":"Number",
         "required":false,
         "length":null,
         "precision":32,
         "scale":0,
         "id":1,
         "postgresql":{
            "columnName":"id",
            "dataType":"integer",
            "dataLength":null,
            "dataPrecision":32,
            "dataScale":0,
            "nullable":"NO"
         }
      },
      "managed":{
         "type":"Boolean",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"managed",
            "dataType":"boolean",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"NO"
         }
      },
      "address":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"address",
            "dataType":"character varying",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"NO"
         }
      },
      "type":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"type",
            "dataType":"character varying",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"NO"
         }
      },
      "userId":{
         "type":"Number",
         "required":false,
         "length":null,
         "precision":32,
         "scale":0,
         "postgresql":{
            "columnName":"user_id",
            "dataType":"integer",
            "dataLength":null,
            "dataPrecision":32,
            "dataScale":0,
            "nullable":"YES"
         }
      },
      "tag":{
         "type":"Number",
         "required":false,
         "length":null,
         "precision":32,
         "scale":0,
         "postgresql":{
            "columnName":"tag",
            "dataType":"integer",
            "dataLength":null,
            "dataPrecision":32,
            "dataScale":0,
            "nullable":"YES"
         }
      },
      "secret":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"secret",
            "dataType":"character varying",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"YES"
         }
      },
      "previousTransactionHash":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"previous_transaction_hash",
            "dataType":"character varying",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"YES"
         }
      },
      "createdat":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"createdAt",
            "dataType":"timestamp without time zone",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"YES"
         }
      },
      "updatedat":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"updatedAt",
            "dataType":"timestamp without time zone",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"YES"
         }
      },
      "uid":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"uid",
            "dataType":"character varying",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"YES"
         }
      },
      "data":{
         "type":"String",
         "required":false,
         "length":null,
         "precision":null,
         "scale":null,
         "postgresql":{
            "columnName":"data",
            "dataType":"text",
            "dataLength":null,
            "dataPrecision":null,
            "dataScale":null,
            "nullable":"YES"
         }
      }
   },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": []
}

The above model was generated by doing:

var loopback = require('loopback');
var ds = loopback.createDataSource('postgresql', {
  "host": "127.0.0.1",
  "port": 5432,
  "database": "db",
  "username": "user",
  "password": ""
});

ds.discoverSchema('addresses', {}, function(er, schema) {
  console.log(JSON.stringify(schema, null, '  '));
});

I can't seem to figure out why it can't map the createdat column. Thanks in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions