小编Kri*_*nya的帖子

无法过滤非节点参数 - 数据存储区 - 谷歌应用引擎 - python

Class user(ndb.Model):
  def post(self):
    name = db.StringProperty()
    age = db.StringProperty()
Class search(webapp2.RequestHandler):
  def post(self):
    x = userData.query().filter("age >=",1)  #error points to this line
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:无法过滤非Node参数; 收到'年龄> ='

我遵循https://developers.google.com/appengine/docs/python/datastore/queries中提到的语法

请让我知道如何解决此问题.

python google-app-engine google-cloud-datastore

8
推荐指数
1
解决办法
5417
查看次数

谷歌应用引擎 - ndb查询只能在python中获取几列

在谷歌应用程序引擎中,是否可以查询数据库只获取某些列?

例如,我有一个模型定义如下:

class userData(ndb.Model):
    id = ndb.StringProperty()
    name = ndb.StringProperty()
    emailAddress = ndb.StringProperty()
Run Code Online (Sandbox Code Playgroud)

我通常查询db如下:

userData.query().filter(ndb.GenericProperty('id') == "requiredId").fetch()
Run Code Online (Sandbox Code Playgroud)

但这给了我包含id,姓名和电子邮件的结果.

现在我想只获取id和name但不是emailAddress.我怎样才能做到这一点?

谢谢!

python google-app-engine app-engine-ndb google-cloud-datastore

4
推荐指数
1
解决办法
2421
查看次数

如何限制子类覆盖/实现超类方法

我有一个抽象方法method1和method2的抽象类.我有扩展抽象类的类A,B和C.

我的问题是如何限制B类仅覆盖方法2?我希望所有其他类能够按意愿覆盖任何方法.

如果使用抽象类不可能这样做,是否可以使用接口实现这种情况?如果是这样,你能用一个例子向我解释一下吗?

这是我想要实现的一个这样的案例.抽象类鸟有抽象方法fly().我希望老鹰能够覆盖它而不是类企鹅

    abstract class bird{
            abstract void fly();
    }
    class eagle extends bird{
            @override
            void fly(){
                    Sysout("I can fly really high!");
    }

    class penguin extends bird{
            @override
            /*How do I make sure this method is not at overridden, because there are chances that      this method could be accidentally overridden*/
            void fly(){
                    Sysout("I cannot fly");
            }
    }
Run Code Online (Sandbox Code Playgroud)

java inheritance

0
推荐指数
1
解决办法
1620
查看次数