System Information
- Strapi Version: 4.8.2
- Operating System: window 10
- Database: postgres + postgis extension
- Node Version: v14.20.0
- NPM Version: 6.14.17
- Yarn Version: 1.22.1
Now I am using postgres + postgis in strapi project and I write a query inside the controller to fetch the cameras within the 4 coordinates using the following raw query.
const result = await strapi.connections.default.raw(`
SELECT * FROM cameras
WHERE ST_Intersects(
ST_SetSRID(ST_MakePoint(CAST(lng AS numeric), CAST(lat AS numeric)), 4326),
ST_SetSRID(
ST_MakePolygon(
ST_GeomFromText('LINESTRING(
103.85877 1.36543,
103.91112 1.36423,
103.91009 1.33128,
103.85774 1.33042,
103.85877 1.36543
)', 4326)
),
4326
));`
);
[2023-03-24 12:50:49.483] error: select “t0”.* from “public”.“cameras” as “t0” where (“t0”.“id” = $1) limit $2 - invalid input syntax for type integer: “get-cameras-within”
error: select “t0”.* from “public”.“cameras” as “t0” where (“t0”.“id” = $1) limit $2 - invalid input syntax for type integer: “get-cameras-within”
at Parser.parseErrorMessage (H:\projects\strapi-postgis-test\postgis-test\node_modules\pg-protocol\dist\parser.js:287:98)
at Parser.handlePacket (H:\projects\strapi-postgis-test\postgis-test\node_modules\pg-protocol\dist\parser.js:126:29)
at Parser.parse (H:\projects\strapi-postgis-test\postgis-test\node_modules\pg-protocol\dist\parser.js:39:38)
at Socket. (H:\projects\strapi-postgis-test\postgis-test\node_modules\pg-protocol\dist\index.js:11:42)
at Socket.emit (events.js:400:28)
at Socket.emit (domain.js:475:12)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
But when I copy and execute the query in postgresql query command interface. I can query without no error.
Can someone tell me the advice how can I solve the issue? Should I create a pool with pg lib or is there any alternative solutions for that?