MaxNoetzold / y-mongodb-provider

Mongodb database adapter for Yjs
MIT License
47 stars 10 forks source link

Typescript #20

Closed MaxNoetzold closed 3 months ago

MaxNoetzold commented 3 months ago

Rewrote the main library in typescript. Also rewrote the update retrieve functions in a way to actually use the cursor. We can now decide if it makes sense to use a cursor or just retrieve all data at once. the original implementation just didnt made a lot of sense.

@raineorshine, do you have any comments on this pr?

raineorshine commented 3 months ago

I think the original implementation was trying to keep direct access to the db (including cursors) decoupled from the public interface. It all felt pretty tightly coupled to me in practice.

The previous type system did use Typescript, just through JSDOC comments in js files instead of ts files. I'm not sure what advantage it had over a more conventional approach.

Glad to see you continue to improve the library :).

MaxNoetzold commented 3 months ago

Thank you very much for the response.

The previous type system did use TypeScript, just through JSDOC comments in JS files instead of TS files. I'm not sure what advantage it had over a more conventional approach.

I asked this question in the Yjs forum and got an answer from dmonad today. I think I will keep this library in JS to fit the general style of Yjs.

I think the original implementation was trying to keep direct access to the db (including cursors) decoupled from the public interface. It all felt pretty tightly coupled to me in practice.

I see your point. I will close this PR and create a new one where I feel better about the mongo-adapter while keeping the decoupling.

raineorshine commented 3 months ago

Great to see his explanation for the JSDOC types. I don't really use the debugger, so I haven't run into that issue myself, but makes sense!