|
1 | 1 | //maps types from javascript to postgres and vise-versa |
2 | 2 |
|
3 | | -var typeParsers = {}; |
4 | | -//registers a method used to parse a string representing a particular |
5 | | -//oid type into a javascript type |
6 | | -var registerStringTypeParser = function(oid, converter) { |
7 | | - typeParsers[oid] = converter; |
8 | | -}; |
9 | | - |
10 | 3 | //the empty parse function |
11 | 4 | var noParse = function(val) { |
12 | 5 | return val; |
13 | 6 | } |
14 | 7 |
|
15 | | -//returns a function used to convert a specific type (specified by |
16 | | -//oid) into a result javascript type |
17 | | -var getStringTypeParser = function(oid) { |
18 | | - return typeParsers[oid] || noParse; |
19 | | -}; |
20 | | - |
21 | | - |
22 | 8 | //parses PostgreSQL server formatted date strings into javascript date objects |
23 | 9 | var parseDate = function(isoDate) { |
24 | 10 | //TODO this could do w/ a refactor |
@@ -128,6 +114,19 @@ var parseByteA = function(val) { |
128 | 114 | }).replace(/\\\\/g, "\\"), "binary"); |
129 | 115 | } |
130 | 116 |
|
| 117 | +var typeParsers = {}; |
| 118 | +//registers a method used to parse a string representing a particular |
| 119 | +//oid type into a javascript type |
| 120 | +var registerStringTypeParser = function(oid, converter) { |
| 121 | + typeParsers[oid] = converter; |
| 122 | +}; |
| 123 | + |
| 124 | +//returns a function used to convert a specific type (specified by |
| 125 | +//oid) into a result javascript type |
| 126 | +var getStringTypeParser = function(oid) { |
| 127 | + return typeParsers[oid] || noParse; |
| 128 | +}; |
| 129 | + |
131 | 130 | //default string type parser registrations |
132 | 131 | registerStringTypeParser(20, parseInt); |
133 | 132 | registerStringTypeParser(21, parseInt); |
|
0 commit comments