Storing objects that cannot be defined
See original GitHub issueHi, 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:
- Created 10 years ago
- Comments:24
Top GitHub Comments
This doesn’t seem to work yet. For example, defining
leads to this when inserting:
Confirming, works here as well.
Thanks.