diff --git a/laguinho/routes/datasets.py b/laguinho/routes/datasets.py index f578ce9..f60c381 100644 --- a/laguinho/routes/datasets.py +++ b/laguinho/routes/datasets.py @@ -23,22 +23,17 @@ def publish(): result = dataset_metadata.load(request.json, unknown=EXCLUDE) if dataset_exists(result): return jsonify('Dataset already exists'), 409 - datasets_metadata.insert_one(result) + datasets_metadata.insert_one({}, {'_id': False})) del result['_id'] return jsonify(result), 201 @datasets.route("/datasets", methods=['GET'], strict_slashes=False) def get_datasets(): - dsets = list(datasets_metadata.find()) - for ds in dsets: - del ds['_id'] - - return jsonify(dsets) + return jsonify(datasets_metadata.find({}, {'_id': False})) @datasets.route("/datasets/", methods=['GET'], strict_slashes=False) def get_datasets_by_name(name): - search_result = datasets_metadata.find_one_or_404({'name': name}) - del search_result['_id'] + search_result = datasets_metadata.find_one_or_404({'name': name}, {'_id': False})) return jsonify(search_result), 200