Support sparse arrays
See original GitHub issueI can’t seem to create an array with null or undefined values without it getting filtered out.
const Item = new SimpleSchema({
myArray: {
type: Object,
optional: true,
blackbox: true
},
});
const arr = [];
arr[1] = 100;
Items.attachSchema(Items);
Items.update({_id: itemId}, { $set: {myArray: arr} });
The update is creates an array sometimes like this [null]
and sometimes just []
.
I’m using blackbox because I couldn’t find how to create validation for an array with null or undefined values, like [,100]
or [null, 100]
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Sparse Arrays - JavaScript: The Definitive Guide, 6th ... - O'Reilly
Sparse Arrays A sparse array is one in which the elements do not have contiguous indexes starting at 0. Normally, the length property...
Read more >Sparse Arrays · The Julia Language - Julia Documentation
Julia has support for sparse vectors and sparse matrices in the SparseArrays stdlib module. Sparse arrays are arrays that contain enough zeros that...
Read more >Sparse matrix - Wikipedia
In numerical analysis and scientific computing, a sparse matrix or sparse array is a matrix in which most of the elements are zero....
Read more >Working with Sparse Arrays - Wolfram Language Documentation
The main function for generating a sparse array is SparseArray. This can operate on a matrix to generate its sparse representation:.
Read more >Sparse matrices (scipy.sparse) — SciPy v1.9.3 Manual
SciPy 2-D sparse array package for numeric data. ... The lil_matrix class supports basic slicing and fancy indexing with a similar syntax to...
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 FreeTop 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
Top GitHub Comments
@santiagopuentep Maybe but it’s hard to say. Because of the support for modifier objects, every value is run through a
mongo-object
package, which treatsundefined
in a particular way, different fromnull
. It will take some work to step through and see if this is fixable.It will never be valid right now because it doesn’t understand sparse arrays and arrays cannot be blackboxed. You’d have to use
_.compact
to remove thenull
values before validating, or if you need them, then skip validation and skip cleaning whenever you insert/update that array.