ravendb / ravendb-nodejs-client

RavenDB node.js client
MIT License
63 stars 32 forks source link

MetadataInternal on @metadata makes it problematic in Next.js #402

Closed marcuslindblom closed 3 months ago

marcuslindblom commented 9 months ago

When I load a document I get an object looking similar to this:

{
…
“@metadata” : MetadataInternal {…}
}

This seem to cause problems when using for instance Next.js, getting the data in getServerSideProps and when the data is transferred to the frontend components it throws an error saying something like, it only supports plain object. Maybe you should consider to remove MetadataInternal from the result and return a plain JSON object instead?

ayende commented 9 months ago

Can you show the full error and maybe repro code?

ml054 commented 9 months ago

@marcuslindblom We use metadata internal class instead of object to track changes etc.

What about writing interceptor which removes metadata property before going to frontend?

On the other hand passing entire db objects to front might be security issue (but in depends on what you store inside your DB objects).

marcuslindblom commented 9 months ago

@ml054 That is a valid point. Is interceptor a concept or do you mean a projection or something like that?

ml054 commented 9 months ago

By interceptor I meant your custom code which prepares raw entity returned from DB into to user.

ml054 commented 3 months ago

@marcuslindblom can you confirm that suggested solución solves your problem?

marcuslindblom commented 3 months ago

Yes, it works fine.