mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
move functions to increase readability
This commit is contained in:
parent
f888f3b947
commit
7d44d7868d
27
lib/types.js
27
lib/types.js
@ -1,24 +1,10 @@
|
||||
//maps types from javascript to postgres and vise-versa
|
||||
|
||||
var typeParsers = {};
|
||||
//registers a method used to parse a string representing a particular
|
||||
//oid type into a javascript type
|
||||
var registerStringTypeParser = function(oid, converter) {
|
||||
typeParsers[oid] = converter;
|
||||
};
|
||||
|
||||
//the empty parse function
|
||||
var noParse = function(val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
//returns a function used to convert a specific type (specified by
|
||||
//oid) into a result javascript type
|
||||
var getStringTypeParser = function(oid) {
|
||||
return typeParsers[oid] || noParse;
|
||||
};
|
||||
|
||||
|
||||
//parses PostgreSQL server formatted date strings into javascript date objects
|
||||
var parseDate = function(isoDate) {
|
||||
//TODO this could do w/ a refactor
|
||||
@ -128,6 +114,19 @@ var parseByteA = function(val) {
|
||||
}).replace(/\\\\/g, "\\"), "binary");
|
||||
}
|
||||
|
||||
var typeParsers = {};
|
||||
//registers a method used to parse a string representing a particular
|
||||
//oid type into a javascript type
|
||||
var registerStringTypeParser = function(oid, converter) {
|
||||
typeParsers[oid] = converter;
|
||||
};
|
||||
|
||||
//returns a function used to convert a specific type (specified by
|
||||
//oid) into a result javascript type
|
||||
var getStringTypeParser = function(oid) {
|
||||
return typeParsers[oid] || noParse;
|
||||
};
|
||||
|
||||
//default string type parser registrations
|
||||
registerStringTypeParser(20, parseInt);
|
||||
registerStringTypeParser(21, parseInt);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user