adam-cowley / neode

Neo4j OGM for Node.js
MIT License
394 stars 72 forks source link

Does Neode.create<T>(...) async? #162

Open kingpeti opened 3 years ago

kingpeti commented 3 years ago

when using this method it is not working as defined in TS. But when I use async-await everything is fine and the return value from Neode.create<T>(...) is present. To work as expected I think it needs to wrap in promise.

Neode.create<T>(model: string, properties: object): Promise<Neode.Node<T>>;

Am I Correct?

Aqua-4 commented 2 years ago

Yes

LucaProvencal commented 2 years ago

It's in the source: https://github.com/adam-cowley/neode/blob/master/types/index.d.ts#L84, but for some reason when I npm install neode@latest, the line is

create<T>(model: string, properties: object): Neode.Node<T>;

@adam-cowley do you have any ideas? Thanks!

adam-cowley commented 2 years ago

The create service does return a Promise so I get the feeling that neode@latest might not actually be the latest. Could you try version 0.4.7?

LucaProvencal commented 2 years ago

Thanks for the reply. That's the version it installed. The same thing happens with npm install neode@0.4.7.

adam-cowley commented 2 years ago

I have just tried on codesandbox and it seems fine to me. Is it just the code hinting/intellisense that is out of date or is the code failing?

https://codesandbox.io/s/bold-blackburn-5088nm?file=/index.js

LucaProvencal commented 2 years ago

The code works fine without TypeScript. TypeScript compiler throws an error when it shouldn't since the line should be

Neode.create<T>(model: string, properties: object): Promise<Neode.Node<T>>;

instead of

Neode.create<T>(model: string, properties: object): Neode.Node<T>;.

I think it is some problem with the 0.4.7 distribution on NPM. The code doesn't match what is in the repo.

adam-cowley commented 2 years ago

I have just bumped the version number and republished, so hopefully version 0.4.8 will fix the problem.

LucaProvencal commented 2 years ago

@adam-cowley That worked! Thanks. Don't want to speak for @kingpeti but I think we can close this