ravendb/ravendb-nodejs-client

MetadataInternal on @metadata makes it problematic in Next.js

marcuslindblom opened this issue · 6 comments

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

Can you show the full error and maybe repro code?

ml054 commented

@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).

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

ml054 commented

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

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

Yes, it works fine.