question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support sparse arrays

See original GitHub issue

I 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:open
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
aldeedcommented, Apr 29, 2020

@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 treats undefined in a particular way, different from null. It will take some work to step through and see if this is fixable.

1reaction
aldeedcommented, Jun 20, 2017

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 the null values before validating, or if you need them, then skip validation and skip cleaning whenever you insert/update that array.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found