adam-cowley / neode

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

How to use with TypeScript #131

Open taylor009 opened 4 years ago

taylor009 commented 4 years ago

@adam-cowley I was wondering if there were some typescript examples or if neode can be used with typescript yet? If there isn't any I could help out on that.

dcsan commented 3 years ago

I also had this question. Some things would probably have to be ignored like these dynamic requires:

const neode = require('neode')
    .fromEnv()
    .with({
        Movie: require('./models/Movie'),

full model validation would be great, but pretty hard. prisma does this well. You could also look at typegoose which tries to infer types with Mongoose.

adam-cowley commented 3 years ago

Yeah this raises some interesting questions on how this library would be used or could be improved to be more class/decorator oriented like prisma/typegoose. I'm trying to work out whether this is a shift in node/typescript development or whether it should become a separate library. I'd love to hear everyone's thoughts?

taylor009 commented 3 years ago

@adam-cowley I saw your comment I made inside the TypeORM repo about adding the support for neo4j. Might be challenging to replicating fully but I think as the node community shifts more into typescript having the class/decorator demand will increase. I'm not sure how difficult it would be to convert the existing library.

But if we need to split it out I'm willing to dedicate some time to it if needed.

adam-cowley commented 3 years ago

I've started experimenting over here - it's basic at the moment but there are a few lines in the README and a couple of tests. It's quite far removed from neode as it stands at the moment so I may have to think how they might fit together.

https://github.com/adam-cowley/neode-ogm

I'm torn between wanting things to be properly coded (objects, etc) or whether I'd just want something that just works with minimal code/effort. But then if we're creating model files, it's only a few lines more to turn it into a class with annotations.

dcsan commented 3 years ago

do you know this driver? how does it compare? https://drivine.org/

adam-cowley commented 3 years ago

Drivine looks handy for transaction management but it still requires that you write your own queries - something that I'd personally like to avoid if possible by defining the model meta data and let the library take care of writing the queries. Jasper makes some good points under the Object Mapping: header on the homepage.

adam-cowley commented 3 years ago

I've put together a basic example with the typescript repo at https://github.com/adam-cowley/neode-ogm-test

adam-cowley commented 3 years ago

All feedback welcome...

https://github.com/adam-cowley/neode-ogm-test/issues/3