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

add option "castNonArrays" #568

Closed
hasezoey opened this issue Jun 27, 2021 · 5 comments
Closed

add option "castNonArrays" #568

hasezoey opened this issue Jun 27, 2021 · 5 comments
Labels
parity Feature Parity with mongoose | mongodb released

Comments

@hasezoey
Copy link
Member

Which feature

support prop option castNonArrays

no documentation yet, see Automattic/mongoose#10397

Code Examples

// NodeJS: 16.3.0
// MongoDB: 4.2-bionic (Docker)
// import { getModelForClass, prop } from "@typegoose/typegoose"; // @typegoose/typegoose@8.0.0-beta.16
import * as mongoose from "mongoose"; // mongoose@5.12.14

const schema1 = new mongoose.Schema({
  someArray: [{
    type: String,
    castNonArrays: false
  }]
});

const model1 = mongoose.model("model1", schema1);

(async () => {
  await mongoose.connect(`mongodb://localhost:44361/`, { useNewUrlParser: true, dbName: "verifyMASTER", useCreateIndex: true, useUnifiedTopology: true });

  const newdoc = await model1.create({ someArray: "hello" }); // no validation error

  const found = await model1.findById(newdoc);

  console.log(found);

  await mongoose.disconnect();
})();

(Note: this is currently broken code)

@hasezoey hasezoey added the parity Feature Parity with mongoose | mongodb label Jun 27, 2021
@github-actions

This comment has been minimized.

@smolinari
Copy link
Contributor

@hasezoey - Interesting. Shouldn't this issue have been auto-closed with that release or with the PR?

Scott

@hasezoey
Copy link
Member Author

Interesting. Shouldn't this issue have been auto-closed with that release or with the PR?

github only closes issues that are fixed in an commit in the default branch (here its master), but currently its only in beta

@hasezoey
Copy link
Member Author

hasezoey commented Jul 3, 2021

form new info in Automattic/mongoose#10398 (comment), it seems like this option has to be removed again, because it is actually not an property option, but an static option for all SchemaArrays

@github-actions
Copy link

🎉 This issue has been resolved in version 8.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parity Feature Parity with mongoose | mongodb released
Projects
None yet
Development

No branches or pull requests

2 participants