Skip to content

Create metadata dictionary in version 6 #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marcuslindblom opened this issue Sep 4, 2024 · 5 comments
Closed

Create metadata dictionary in version 6 #460

marcuslindblom opened this issue Sep 4, 2024 · 5 comments

Comments

@marcuslindblom
Copy link

In an older project running ravendb 5.4 I import MetadataDictionary like this and use at like the example below.

import { MetadataDictionary } from 'ravendb/dist/Mapping/MetadataAsDictionary';
for (const template of templates.filter((t) => !t.disableURL)) {
    await bulkInsert.store(template, `templates/${template.collection}`, createMetadataDictionary({ '@collection': 'Templates' }));
}

But when running ravendb 6 it does not exist, so how can I do this in the latest version?

@ml054
Copy link
Contributor

ml054 commented Sep 4, 2024

@marcuslindblom Looks like we didn't expose MetadataAsDictionary from index.ts in package.

I'm reporting this as an issue.
As temporary workaround you can use:

                    await bulkInsert.store(new Company(), "test/" + i, {
                        isDirty(): boolean {
                            return false;
                        },
                        "@collection": "Test1"
                    })

@ml054
Copy link
Contributor

ml054 commented Sep 4, 2024

@marcuslindblom
Copy link
Author

Thanks!

When using nodejs and typescript, should I add something similar to Raven-Clr-Type?

@ml054
Copy link
Contributor

ml054 commented Sep 4, 2024

If you are creating new project you can use ClassTransformer which was introduced in v6.0.

It is listed here:
https://github.com/ravendb/ravendb-nodejs-client/releases/tag/6.0.0
and detailed link to example:

class ClassTransformer implements ITypesAwareObjectMapper {

Then we won't need nested fields types (to keep info that field is date).

And you don't need Raven-Clr-Type as well.

@ml054
Copy link
Contributor

ml054 commented Sep 17, 2024

Fixed in #463

@ml054 ml054 closed this as completed Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants