Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema in settings don't delete extra keys from MongoDB document #52

Closed
tsileo opened this issue May 8, 2013 · 3 comments
Closed

Schema in settings don't delete extra keys from MongoDB document #52

tsileo opened this issue May 8, 2013 · 3 comments

Comments

@tsileo
Copy link
Contributor

tsileo commented May 8, 2013

Hi,

With latest Eve, here is my schema:

incidents = {
    'item_title': 'incident',
    'auth_username_field': 'user',
    'resource_methods': ['GET'],
    'item_methods': ['GET'],
    'schema': {
        'key': {
            'type': 'string',
        },
        'interval': {
            'type': 'integer',
        },
        'interval_human': {
            'type': 'string',
        },
        'last_backup_size': {
            'type': 'integer',
        },
        'last_backup_size_human': {
            'type': 'string',
        },
        'last_backup_date_utc': {
            'type': 'string',
        },
        'last_backup_date_human': {
            'type': 'string',
        },
        'last_backup_host': {
            'type': 'string',
        },
    }
}

And here is what I get on GET:

{
  "_items": [
    {
      "_id": "518a3b908e3e02522dfe98d0", 
      "_links": {
        "self": {
          "href": "localhost:2404/api/incidents/518a3b908e3e02522dfe98d0/", 
          "title": "incident"
        }
      }, 
      "cal_ts": 1368013712, 
      "cal_ts_utc": 1368006512, 
      "call_ts_ago": "2013/05/08 13:48:32", 
      "created": "Thu, 01 Jan 1970 00:00:00 UTC", 
      "etag": "17c536402d8b29c766489e6467821c5f2cd8014b", 
      "interval": 301, 
      "interval_human": "301s", 
      "key": "check", 
      "last_backup_date": "2013/05/08 13:41:54", 
      "last_backup_date_utc": "Wed, 08 May 2013 11:41:54 UTC", 
      "last_backup_host": "tomt0m", 
      "last_backup_size": 9999, 
      "last_backup_size_human": "10.0 KB", 
      "login": "thomas", 
      "updated": "Thu, 01 Jan 1970 00:00:00 UTC"
    }
  ], 
  "_links": {
    "parent": {
      "href": "localhost:2404/api", 
      "title": "home"
    }, 
    "self": {
      "href": "localhost:2404/api/incidents/", 
      "title": "incidents"
    }
  }
}

From what I understand, these keys: "cal_ts": 1368013712,
"cal_ts_utc": 1368006512,
"call_ts_ago": "2013/05/08 13:48:32",
should be removed from response right ?

Any thoughts ?

@nicolaiarocci
Copy link
Member

Ooook now I see what you meant on twitter, my bad I didn't get it right. Making it a feature request.

@nicolaiarocci
Copy link
Member

This also allowed me properly implement resource.datasource.projection (which was not documented but was in place already) and also to add a security layer to the Projections feature. Also check the updated docs for reference http://python-eve.org/config.html#advanced-datasource-patterns. - thanks!

@tsileo
Copy link
Contributor Author

tsileo commented May 9, 2013

Awesome! Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants