Arrays without the option "type" or "items" makes array "Mixed" (adding array in array)
See original GitHub issueVersions
- NodeJS: 12.0.0
- Typegoose(NPM): 7.x.x
- Typegoose(GIT): commithash
- mongoose: 5.9.20
- mongodb: 3.5.9
What is the Problem?
Arrays prior to 7.1.0 are stored correctly. In versions later than 7.1 each element is nested in an own array:
Code Example
class Example {
@prop()
public arrayExample!: string[]
}
const arrayExample: ["1","2","3"]
new Example({arrayExample}).save()
My expectations in DB are:
{
_id: ...,
arrayExample: ["1","2","3"]
}
Its instead:
{
_id: ...,
arrayExample: [["1"],["2"],["3"]]
}
Do you know why it happenes?
no
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Q&A: How to create an array with mixed types in Swift?
While creating an array that contains instances of just one of the above two types is really straightforward — we just use either...
Read more >Defining array with multiple types in TypeScript - Stack Overflow
This won't work with complex types with different properties, when you want to access a property available on only one of the types....
Read more >Arrays - The Modern JavaScript Tutorial
If new Array is called with a single argument which is a number, then it creates an array without items, but with the...
Read more >Chapter 10. Arrays
There are some situations in which an element of an array can be an array: if the element type is Object or Cloneable...
Read more >Array Types - JavaScript. Flow
You can put any type within Array<Type> . 1 2 3, let arr1: Array< ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Note the
items:String
.Scott
@henhen724 please give an example on how you try to set it (btw, did you try to do
type: [String]
? when yes, this is only available since 7.4.0)