Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

remoção do _id #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions laguinho/routes/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
lucascarrafa marked this conversation as resolved.
Show resolved Hide resolved
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/<name>", 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