mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
* Work on converting lib to standard * Finish updating lib * Finish linting lib * Format test files * Add .eslintrc with standard format * Supply full path to eslint bin * Move lint command to package.json * Add eslint as dev dependency
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
'use strict'
|
|
/**
|
|
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* README.md file in the root directory of this source tree.
|
|
*/
|
|
|
|
var NativeResult = module.exports = function (pq) {
|
|
this.command = null
|
|
this.rowCount = 0
|
|
this.rows = null
|
|
this.fields = null
|
|
}
|
|
|
|
NativeResult.prototype.addCommandComplete = function (pq) {
|
|
this.command = pq.cmdStatus().split(' ')[0]
|
|
this.rowCount = parseInt(pq.cmdTuples(), 10)
|
|
var nfields = pq.nfields()
|
|
if (nfields < 1) return
|
|
|
|
this.fields = []
|
|
for (var i = 0; i < nfields; i++) {
|
|
this.fields.push({
|
|
name: pq.fname(i),
|
|
dataTypeID: pq.ftype(i)
|
|
})
|
|
}
|
|
}
|
|
|
|
NativeResult.prototype.addRow = function (row) {
|
|
// This is empty to ensure pg code doesn't break when switching to pg-native
|
|
// pg-native loads all rows into the final result object by default.
|
|
// This is because libpg loads all rows into memory before passing the result
|
|
// to pg-native.
|
|
}
|