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.

Storing objects that cannot be defined

See original GitHub issue

Hi, we are creating an application that needs to save user generated data. The user uploads a csv file and we create a document for each of the rows of the csv file. We later use the data in the csv in lists, edit screens and to pass to other parts of the application.

The problem we are having is that every csv file can have a different column definition. This makes it almost impossible to validate the rest of the docment we are inserting, as simple-schema does not allow black box objects (the csv data needs to be a key-value object).

Example pseudocode:

CSV = new Meteor.Collection2('csv', {
    schema: {
        uploadId: {
            type: String,
            label: "data is part of this upload"
        },
        data: {
            type: Object,
            label: "Answers in csv"
        }
    }
});

csv_data = {
    uploadId: "1234567890",
    data: {
                COL1: 1,
                COL2: "some string",
                COL3: 3.324,
                COL4: 4
    }
};

Would there be no way of telling simple-schema to just accept the object and ignore what else is in there? It is not an option for us to JSON.stringify the data as suggested earlier as we use this data all over our application, and very often want to access the data from a column directly (data.COL1 for instance) in Mongo queries (in C++ applications). The csv data can be a very large object.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:24

github_iconTop GitHub Comments

1reaction
advancingucommented, Jan 24, 2014

This doesn’t seem to work yet. For example, defining

Testing = new Meteor.Collection("testing", {
  schema: new SimpleSchema({
    myval: {
      type: Object,
      blackbox: true
    }
  })
});

leads to this when inserting:

Testing.insert({myval: {adsad: 'adsad'}})
insert failed: Error: failed validation: undefined is not allowed by the schema
    at doValidate (http://localhost:3000/packages/collection2.js?76b52f96f3edde1cdb74529107f5a62b68ed65f3:459:13)
0reactions
advancingucommented, Jan 27, 2014

Confirming, works here as well.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is Object Storage? - Object vs. File vs. Block | NetApp
Object storage, also known as object-based storage, is a strategy that manages and manipulates data storage as distinct units, called objects.
Read more >
Object Storage: An Introduction | IBM
Object storage, often referred to as object-based storage, is a data storage architecture for handling large amounts of unstructured data.
Read more >
Why can ArrayLists store different object while arrays cannot?
ArrayList has a field called Object[] elementData which means an ArrayList supports adding every kind of object reference.
Read more >
Immutable object - Wikipedia
In object-oriented and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created.
Read more >
Storage Object (STORE) - Documentation
Storage objects allow you to upload a file and store it in binary format in the database. Object Definition. Object class: Passive object....
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