how could I achieve a sort of a dynamic datasource got from the incoming post-payload ? So all incoming payloads "create" a new collection in mongodb or use the old one if available...
Ex. payload: {"a1": "999", "d1": "06.05.2020 04:29:16", "d2": "0", "d3": "0", "id2": "3777"}
part of settings.py:
mdata = {
'schema': {
**'a1': {
'type': 'string'**
},
'd1': {
'type': 'string'
},
'd2': {
'type': 'string'
},
'd3': {
'type': 'string'
},
'id2': {
'type': 'string'
}
},
'datasource': {
**'source': "a1-value" #should be 'a1' value from the post payload**
},
"resource_methods": ["POST"],
}
DOMAIN = {
"accounts": accounts,
"user": user,
"mdata": madata,
}
In the
eve, the collection name is your resource name:for example, assume that this is your
DOMAIN:so when you request this endpoint a collection with a
testname is created.But the
sourceisI suggest reading this section of the document:
https://docs.python-eve.org/en/stable/config.html#advanced-datasource-patterns