Skip to content

Commit c33b8c1

Browse files
committed
Rename db to database to conform with other drivers
1 parent db0977a commit c33b8c1

19 files changed

+128
-110
lines changed

src/driver.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ class Driver {
111111

112112
/**
113113
* Verifies connectivity of this driver by trying to open a connection with the provided driver options.
114-
* @param {string} [db=''] the target database to verify connectivity for.
114+
* @param {string} [database=''] the target database to verify connectivity for.
115115
* @returns {Promise<object>} promise resolved with server info or rejected with error.
116116
*/
117-
verifyConnectivity ({ db = '' } = {}) {
117+
verifyConnectivity ({ database = '' } = {}) {
118118
const connectionProvider = this._getOrCreateConnectionProvider()
119119
const connectivityVerifier = new ConnectivityVerifier(connectionProvider)
120-
return connectivityVerifier.verify({ db })
120+
return connectivityVerifier.verify({ database })
121121
}
122122

123123
/**
@@ -194,13 +194,13 @@ class Driver {
194194
* @param {string} [defaultAccessMode=WRITE] the access mode of this session, allowed values are {@link READ} and {@link WRITE}.
195195
* @param {string|string[]} [bookmarks=null] the initial reference or references to some previous
196196
* transactions. Value is optional and absence indicates that that the bookmarks do not exist or are unknown.
197-
* @param {string} [db=''] the database this session will connect to.
197+
* @param {string} [database=''] the database this session will connect to.
198198
* @return {Session} new session.
199199
*/
200200
session ({
201201
defaultAccessMode = WRITE,
202202
bookmarks: bookmarkOrBookmarks,
203-
db = ''
203+
database = ''
204204
} = {}) {
205205
const sessionMode = Driver._validateSessionMode(defaultAccessMode)
206206
const connectionProvider = this._getOrCreateConnectionProvider()
@@ -209,7 +209,7 @@ class Driver {
209209
: Bookmark.empty()
210210
return new Session({
211211
mode: sessionMode,
212-
db,
212+
database,
213213
connectionProvider,
214214
bookmark,
215215
config: this._config

src/internal/bolt-protocol-util.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ function assertTxConfigIsEmpty (txConfig, connection, observer) {
3939

4040
/**
4141
* Asserts that the passed-in database name is empty.
42-
* @param {string} db
42+
* @param {string} database
4343
* @param {Connection} connection
4444
* @param {StreamObserver} observer
4545
*/
46-
function assertDbIsEmpty (db, connection, observer) {
47-
if (db) {
46+
function assertDatabaseIsEmpty (database, connection, observer) {
47+
if (database) {
4848
const error = newError(
4949
'Driver is connected to the database that does not support multiple databases. ' +
5050
'Please upgrade to neo4j 4.0.0 or later in order to use this functionality'
@@ -57,4 +57,4 @@ function assertDbIsEmpty (db, connection, observer) {
5757
}
5858
}
5959

60-
export { assertDbIsEmpty, assertTxConfigIsEmpty }
60+
export { assertDatabaseIsEmpty, assertTxConfigIsEmpty }

src/internal/bolt-protocol-v1.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import * as v1 from './packstream-v1'
2121
import Bookmark from './bookmark'
2222
import TxConfig from './tx-config'
2323
import { ACCESS_MODE_WRITE } from './constants'
24-
import { assertDbIsEmpty, assertTxConfigIsEmpty } from './bolt-protocol-util'
24+
import {
25+
assertDatabaseIsEmpty,
26+
assertTxConfigIsEmpty
27+
} from './bolt-protocol-util'
2528

2629
export default class BoltProtocol {
2730
/**
@@ -81,12 +84,12 @@ export default class BoltProtocol {
8184
* @param {StreamObserver} observer the response observer.
8285
* @param {Bookmark} bookmark the bookmark.
8386
* @param {TxConfig} txConfig the configuration.
84-
* @param {string} db the target database name.
87+
* @param {string} database the target database name.
8588
* @param {string} mode the access mode.
8689
*/
87-
beginTransaction (observer, { bookmark, txConfig, db, mode }) {
90+
beginTransaction (observer, { bookmark, txConfig, database, mode }) {
8891
assertTxConfigIsEmpty(txConfig, this._connection, observer)
89-
assertDbIsEmpty(db, this._connection, observer)
92+
assertDatabaseIsEmpty(database, this._connection, observer)
9093

9194
const runMessage = RequestMessage.run(
9295
'BEGIN',
@@ -133,14 +136,14 @@ export default class BoltProtocol {
133136
* @param {StreamObserver} observer the response observer.
134137
* @param {Bookmark} bookmark the bookmark.
135138
* @param {TxConfig} txConfig the auto-commit transaction configuration.
136-
* @param {string} db the target database name.
139+
* @param {string} database the target database name.
137140
* @param {string} mode the access mode.
138141
*/
139-
run (statement, parameters, observer, { bookmark, txConfig, db, mode }) {
142+
run (statement, parameters, observer, { bookmark, txConfig, database, mode }) {
140143
// bookmark and mode are ignored in this version of the protocol
141144
assertTxConfigIsEmpty(txConfig, this._connection, observer)
142-
// passing in a db name on this protocol version throws an error
143-
assertDbIsEmpty(db, this._connection, observer)
145+
// passing in a database name on this protocol version throws an error
146+
assertDatabaseIsEmpty(database, this._connection, observer)
144147

145148
const runMessage = RequestMessage.run(statement, parameters)
146149
const pullAllMessage = RequestMessage.pullAll()

src/internal/bolt-protocol-v3.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
import BoltProtocolV2 from './bolt-protocol-v2'
2020
import RequestMessage from './request-message'
21-
import { assertDbIsEmpty } from './bolt-protocol-util'
21+
import { assertDatabaseIsEmpty } from './bolt-protocol-util'
2222

2323
export default class BoltProtocol extends BoltProtocolV2 {
2424
transformMetadata (metadata) {
@@ -48,8 +48,8 @@ export default class BoltProtocol extends BoltProtocolV2 {
4848
this._connection.write(message, observer, true)
4949
}
5050

51-
beginTransaction (observer, { bookmark, txConfig, db, mode }) {
52-
assertDbIsEmpty(db, this._connection, observer)
51+
beginTransaction (observer, { bookmark, txConfig, database, mode }) {
52+
assertDatabaseIsEmpty(database, this._connection, observer)
5353
prepareToHandleSingleResponse(observer)
5454
const message = RequestMessage.begin({ bookmark, txConfig, mode })
5555
this._connection.write(message, observer, true)
@@ -67,9 +67,9 @@ export default class BoltProtocol extends BoltProtocolV2 {
6767
this._connection.write(message, observer, true)
6868
}
6969

70-
run (statement, parameters, observer, { bookmark, txConfig, db, mode }) {
71-
// passing in a db name on this protocol version throws an error
72-
assertDbIsEmpty(db, this._connection, observer)
70+
run (statement, parameters, observer, { bookmark, txConfig, database, mode }) {
71+
// passing in a database name on this protocol version throws an error
72+
assertDatabaseIsEmpty(database, this._connection, observer)
7373

7474
const runMessage = RequestMessage.runWithMetadata(statement, parameters, {
7575
bookmark,

src/internal/bolt-protocol-v4.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import BoltProtocolV3 from './bolt-protocol-v3'
2020
import RequestMessage from './request-message'
2121

2222
export default class BoltProtocol extends BoltProtocolV3 {
23-
beginTransaction (observer, { bookmark, txConfig, db, mode }) {
24-
const message = RequestMessage.begin({ bookmark, txConfig, db, mode })
23+
beginTransaction (observer, { bookmark, txConfig, database, mode }) {
24+
const message = RequestMessage.begin({ bookmark, txConfig, database, mode })
2525
this._connection.write(message, observer, true)
2626
}
2727

28-
run (statement, parameters, observer, { bookmark, txConfig, db, mode }) {
28+
run (statement, parameters, observer, { bookmark, txConfig, database, mode }) {
2929
const runMessage = RequestMessage.runWithMetadata(statement, parameters, {
3030
bookmark,
3131
txConfig,
32-
db,
32+
database,
3333
mode
3434
})
3535
const pullMessage = RequestMessage.pull()

src/internal/connection-holder.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ export default class ConnectionHolder {
2828
/**
2929
* @constructor
3030
* @param {string} mode - the access mode for new connection holder.
31-
* @param {string} db - the target database name.
31+
* @param {string} database - the target database name.
3232
* @param {ConnectionProvider} connectionProvider - the connection provider to acquire connections from.
3333
*/
34-
constructor ({ mode = ACCESS_MODE_WRITE, db = '', connectionProvider } = {}) {
34+
constructor ({
35+
mode = ACCESS_MODE_WRITE,
36+
database = '',
37+
connectionProvider
38+
} = {}) {
3539
this._mode = mode
36-
this._db = db ? assertString(db, 'db') : ''
40+
this._database = database ? assertString(database, 'database') : ''
3741
this._connectionProvider = connectionProvider
3842
this._referenceCount = 0
3943
this._connectionPromise = Promise.resolve(null)
@@ -49,10 +53,10 @@ export default class ConnectionHolder {
4953

5054
/**
5155
* Returns the target database name
52-
* @returns {string} db name
56+
* @returns {string} the database name
5357
*/
54-
db () {
55-
return this._db
58+
database () {
59+
return this._database
5660
}
5761

5862
/**
@@ -63,7 +67,7 @@ export default class ConnectionHolder {
6367
if (this._referenceCount === 0) {
6468
this._connectionPromise = this._connectionProvider.acquireConnection(
6569
this._mode,
66-
this._db
70+
this._database
6771
)
6872
}
6973
this._referenceCount++

src/internal/connection-providers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { HostNameResolver } from './node'
2828
const UNAUTHORIZED_ERROR_CODE = 'Neo.ClientError.Security.Unauthorized'
2929

3030
class ConnectionProvider {
31-
acquireConnection (accessMode, db) {
31+
acquireConnection (accessMode, database) {
3232
throw new Error('Abstract function')
3333
}
3434

@@ -51,7 +51,7 @@ export class DirectConnectionProvider extends ConnectionProvider {
5151
this._driverOnErrorCallback = driverOnErrorCallback
5252
}
5353

54-
acquireConnection (accessMode, db) {
54+
acquireConnection (accessMode, database) {
5555
const connectionPromise = this._connectionPool.acquire(this._address)
5656
return this._withAdditionalOnErrorCallback(
5757
connectionPromise,
@@ -83,7 +83,7 @@ export class LoadBalancer extends ConnectionProvider {
8383
this._useSeedRouter = true
8484
}
8585

86-
acquireConnection (accessMode, db) {
86+
acquireConnection (accessMode, database) {
8787
const connectionPromise = this._freshRoutingTable(accessMode).then(
8888
routingTable => {
8989
if (accessMode === READ) {
@@ -357,7 +357,7 @@ export class SingleConnectionProvider extends ConnectionProvider {
357357
this._connection = connection
358358
}
359359

360-
acquireConnection (mode, db) {
360+
acquireConnection (mode, database) {
361361
const connection = this._connection
362362
this._connection = null
363363
return Promise.resolve(connection)

src/internal/connectivity-verifier.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default class ConnectivityVerifier {
3737
* Try to obtain a working connection from the connection provider.
3838
* @returns {Promise<object>} promise resolved with server info or rejected with error.
3939
*/
40-
verify ({ db = '' } = {}) {
41-
return acquireAndReleaseDummyConnection(this._connectionProvider, db)
40+
verify ({ database = '' } = {}) {
41+
return acquireAndReleaseDummyConnection(this._connectionProvider, database)
4242
}
4343
}
4444

@@ -47,10 +47,10 @@ export default class ConnectivityVerifier {
4747
* @param {ConnectionProvider} connectionProvider the provider to obtain connections from.
4848
* @return {Promise<object>} promise resolved with server info or rejected with error.
4949
*/
50-
function acquireAndReleaseDummyConnection (connectionProvider, db) {
50+
function acquireAndReleaseDummyConnection (connectionProvider, database) {
5151
const connectionHolder = new ConnectionHolder({
5252
mode: READ,
53-
db,
53+
database,
5454
connectionProvider
5555
})
5656
connectionHolder.initializeConnection()

src/internal/http/http-session.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ import { EMPTY_CONNECTION_HOLDER } from '../connection-holder'
2626
import Result from '../../result'
2727

2828
export default class HttpSession extends Session {
29-
constructor ({ url, authToken, config, db = '', sessionTracker } = {}) {
30-
super({ mode: WRITE, connectionProvider: null, bookmark: null, db, config })
29+
constructor ({ url, authToken, config, database = '', sessionTracker } = {}) {
30+
super({
31+
mode: WRITE,
32+
connectionProvider: null,
33+
bookmark: null,
34+
database,
35+
config
36+
})
3137
this._ongoingTransactionIds = []
3238
this._serverInfoSupplier = createServerInfoSupplier(url)
3339
this._requestRunner = new HttpRequestRunner(url, authToken)

src/internal/request-message.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ export default class RequestMessage {
115115
* Create a new BEGIN message.
116116
* @param {Bookmark} bookmark the bookmark.
117117
* @param {TxConfig} txConfig the configuration.
118-
* @param {string} db the database name.
118+
* @param {string} database the database name.
119119
* @param {string} mode the access mode.
120120
* @return {RequestMessage} new BEGIN message.
121121
*/
122-
static begin ({ bookmark, txConfig, db, mode } = {}) {
123-
const metadata = buildTxMetadata(bookmark, txConfig, db, mode)
122+
static begin ({ bookmark, txConfig, database, mode } = {}) {
123+
const metadata = buildTxMetadata(bookmark, txConfig, database, mode)
124124
return new RequestMessage(
125125
BEGIN,
126126
[metadata],
@@ -150,16 +150,16 @@ export default class RequestMessage {
150150
* @param {object} parameters the statement parameters.
151151
* @param {Bookmark} bookmark the bookmark.
152152
* @param {TxConfig} txConfig the configuration.
153-
* @param {string} db the database name.
153+
* @param {string} database the database name.
154154
* @param {string} mode the access mode.
155155
* @return {RequestMessage} new RUN message with additional metadata.
156156
*/
157157
static runWithMetadata (
158158
statement,
159159
parameters,
160-
{ bookmark, txConfig, db, mode } = {}
160+
{ bookmark, txConfig, database, mode } = {}
161161
) {
162-
const metadata = buildTxMetadata(bookmark, txConfig, db, mode)
162+
const metadata = buildTxMetadata(bookmark, txConfig, database, mode)
163163
return new RequestMessage(
164164
RUN,
165165
[statement, parameters, metadata],
@@ -213,11 +213,11 @@ export default class RequestMessage {
213213
* Create an object that represent transaction metadata.
214214
* @param {Bookmark} bookmark the bookmark.
215215
* @param {TxConfig} txConfig the configuration.
216-
* @param {string} db the database name.
216+
* @param {string} database the database name.
217217
* @param {string} mode the access mode.
218218
* @return {object} a metadata object.
219219
*/
220-
function buildTxMetadata (bookmark, txConfig, db, mode) {
220+
function buildTxMetadata (bookmark, txConfig, database, mode) {
221221
const metadata = {}
222222
if (!bookmark.isEmpty()) {
223223
metadata['bookmarks'] = bookmark.values()
@@ -228,8 +228,8 @@ function buildTxMetadata (bookmark, txConfig, db, mode) {
228228
if (txConfig.metadata) {
229229
metadata['tx_metadata'] = txConfig.metadata
230230
}
231-
if (db) {
232-
metadata['db'] = assertString(db, 'db')
231+
if (database) {
232+
metadata['db'] = assertString(database, 'database')
233233
}
234234
if (mode === ACCESS_MODE_READ) {
235235
metadata['mode'] = READ_MODE

0 commit comments

Comments
 (0)