Skip to content

Commit

Permalink
update dependencies (neo4j-driver 5.8.0 & nestjs 9.4)
Browse files Browse the repository at this point in the history
update neo4j docker image to neo4j:5.7.0-enterprise
add getConfig in Neo4jService
add support of disableLosslessIntegers in toNeo4j and fromNeo4j in Neo4jModelService this fixes #2
Use Number() instead of toNumber conversion which also work on number and Neo4j returned Integer
fix some unit test names
add e2e and unit tests to cover disableLosslessIntegers Neo4j config on cats example
  • Loading branch information
Popotojs committed May 15, 2023
1 parent 3681a92 commit 316d9ac
Show file tree
Hide file tree
Showing 16 changed files with 1,004 additions and 303 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'

services:
neo4j:
image: neo4j:5.5.0-enterprise
image: neo4j:5.7.0-enterprise
restart: unless-stopped
ports:
- "7474:7474"
Expand Down
8 changes: 6 additions & 2 deletions lib/service/neo4j.model.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export abstract class Neo4jModelService<T> {
public toNeo4j(params: Partial<T>): Record<string, any> {
let result: Record<string, any> = { ...params };
if (this.timestamp && params && params[this.timestamp]) {
result[this.timestamp] = int(params[this.timestamp].getTime());
if (this.neo4jService.getConfig().disableLosslessIntegers) {
result[this.timestamp] = params[this.timestamp].getTime();
} else {
result[this.timestamp] = int(params[this.timestamp].getTime());
}
}
return { ...result };
}
Expand All @@ -44,7 +48,7 @@ export abstract class Neo4jModelService<T> {
public fromNeo4j(record: Record<string, any>): T {
let result: Record<string, any> = { ...record };
if (this.timestamp && record && record[this.timestamp]) {
result[this.timestamp] = new Date(result[this.timestamp].toNumber());
result[this.timestamp] = new Date(Number(result[this.timestamp]));
}
return result as T;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/service/neo4j.node.model.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export abstract class Neo4jNodeModelService<T> extends Neo4jModelService<T> {
run: async () => {
const res = await this._run(query);
return res.map(
(r) => <[T, number]>[this.fromNeo4j(r.matched), r.score.toNumber()],
(r) => <[T, number]>[this.fromNeo4j(r.matched), Number(r.score)],
);
},
};
Expand Down
4 changes: 4 additions & 0 deletions lib/service/neo4j.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export class Neo4jService implements OnApplicationShutdown {
};
}

getConfig() {
return this.config;
}

/**
* Verifies connectivity of this driver by trying to open a connection with the provided driver options.
*/
Expand Down
Loading

0 comments on commit 316d9ac

Please sign in to comment.