Comments (3)
With records the best you can get is an array of strings, right? Since there is no type information. If that's all you want, you could try plugging in something like this: https://github.com/boromisp/postgres-composite. And for the array of records type you would combine that with https://github.com/bendrucker/postgres-array.
from node-pg-types.
That is true: Records are just arrays of strings or nulls. The data itself will be a a text string which can be decoded to array of strings and nulls.
I think it is possible to define types to them and I think then PostgreSQL would give more information in the fields section of the response -- probably the name/OID of the type -- but I have not tested this.
I actually made a parser function for record strings yesterday:
- The parser implementation for ROWs (ugly :) ) https://github.com/heusalagroup/fi.hg.repository/blob/main/persisters/pg/PgOidParserUtils.ts#L19
- Unit tests for it: https://github.com/heusalagroup/fi.hg.repository/blob/main/persisters/pg/PgOidParserUtils.test.ts
I don't have a parser for an array of ROWs though. Those two modules look promising. Although we don't usually want to introduce new dependencies to our zero dep core modules.
(PS: However, for my initial problem I ended up using JSON instead -- just changed those BIGINT fields to use ::text
)
from node-pg-types.
Based on the discussion here I don't see this getting added. If this were possible it's probably useful:
I think it is possible to define types to them and I think then PostgreSQL would give more information in the fields section of the response -- probably the name/OID of the type -- but I have not tested this.
Otherwise, this seems best as an exercise left to the user, since as noted you can at best parse the original entries and then still need application-specific code to convert to the correct type from a string.
from node-pg-types.
Related Issues (20)
- Parser not working for bigint values HOT 3
- Can I customize type parsing per query? HOT 3
- please throw when oid is nullish HOT 1
- Reuse postgres-bytea HOT 6
- Releasing the latest changes HOT 4
- parsing postgres box type? HOT 2
- should handle null values HOT 1
- overriding a type parser HOT 1
- Does full text search with to_tsquery work ? HOT 1
- Is the Date parsing fix in the current pg release? HOT 1
- How to import pg-types using ES6 syntax? HOT 2
- Not able to use with modules HOT 1
- +num over parseInt(num, 10) HOT 1
- Changelog with breaking changes? HOT 1
- Can this package be used in the browser? HOT 2
- Tracking down geometry oids HOT 3
- Readme. What number represents what type. HOT 2
- types.setTypeParser(types.builtins.DATE) does not work
- Numeric values are parsed as strings but arrays of numerics are parsed as number arrays HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-pg-types.