无法搜索 eve rest API - 附加查找不起作用 [英] can't search eve rest API - additional lookup not working

查看:41
本文介绍了无法搜索 eve rest API - 附加查找不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这里的示例进行操作:https://github.com/pyeve/eve-demo/blob/master/settings.py

I was following the example here: https://github.com/pyeve/eve-demo/blob/master/settings.py

当我转到 localhost:5000/apps 时,我可以看到我收藏中的所有文档,但是当我在 localhost:5000/apps/example@gmail.com 上搜索电子邮件时,它显示404 未找到".

When I go to localhost:5000/apps, I can see all the documents in my collection, but when I search for an email at localhost:5000/apps/example@gmail.com, it says '404 not found'.

我已经确认了正则表达式,并且电子邮件地址在文档中.谁能看出哪里出了问题?

I've confirmed the regex, and the email addresses are in the documents. Can anyone see what might be wrong?

运行.py

from eve import Eve


if __name__ == '__main__':
    app = Eve()
    app.run()

settings.py:

settings.py:

RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']


MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'test_database'



apps = {
    'item_title' : 'app',

    'additional_lookup' : {
    'url' : 'regex("\b[\w.-]+?@\w+?\.\w+?\b")',
    'field' : 'developer_email',
    },

        'schema': {
            'address' : {
                'type' : 'string'
                },
            'developer_email' : {
                'type' : 'string',
                'minlength' : 1,
                'maxlength' : 15,
                'required' : True,
                'unique' : True,
            }
            }

DOMAIN = {
    'apps' : apps,
}

推荐答案

在您的 settings.py 中,您没有正确进行查找.应该是.

In your settings.py you aren't doing the lookup correctly. It should be.

apps = {
    'item_title' : 'app',

    'additional_lookup' : {
    'url' : 'apps/regex("\b[\w.-]+?@\w+?\.\w+?\b")',
    'field' : 'developer_email',
    },

        'schema': {
            'address' : {
                'type' : 'string'
                },
            'developer_email' : {
                'type' : 'string',
                'minlength' : 1,
                'maxlength' : 15,
                'required' : True,
                'unique' : True,
            }
            }

这篇关于无法搜索 eve rest API - 附加查找不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆