Skip to content
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

[ORM] mongodb BSONError: No template found for 0 for Array<{...}> #444

Open
CristianPi opened this issue Apr 18, 2023 · 1 comment
Open
Labels
needs-replication Needs replication code

Comments

@CristianPi
Copy link
Contributor

  references: Array<{
    cls: string,
    id: MongoId
  }> = [];

The error is not very clear, but is does not like that Array the way i declared it.

  should create an entity - autocommit disable
/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:724
            throw new model_js_1.BSONError(`No template found for ${member.type.kind}`);
                  ^

BSONError: No template found for 0
    at handleObjectLiteral (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:724:19)
    at sizerObjectLiteral (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:597:5)
    at /home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:1201:96
    at executeTemplates (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/type/dist/cjs/src/serializer.js:651:13)
    at sizerArray (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:1061:43)
    at /home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:1211:96
    at executeTemplates (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/type/dist/cjs/src/serializer.js:651:13)
    at handleObjectLiteral (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:722:54)
    at sizerObjectLiteral (/home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:597:5)
    at /home/cristian/IdeaProjects/base-monorepo-nodejs/node_modules/@deepkit/bson/dist/cjs/src/bson-serializer.js:1202:104

It works using an interface/class and using []

  references: ref[] = [];
@marcj
Copy link
Member

marcj commented May 8, 2023

I just added tests to show that this works as intended, see 373a698. We also have templates assigned to kind=0, so I'm not sure where this error is coming from.

So, please post a full reproduction example if you still get this error in the newest version

@marcj marcj added the needs-replication Needs replication code label May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-replication Needs replication code
Projects
None yet
Development

No branches or pull requests

2 participants