小编vik*_*kin的帖子

如何将参数传递给 ts-node 处理的脚本

我刚开始使用 ts-node。这是一个非常方便的工具。运行时间看起来很清楚。但它不适用于 CLI 解决方案。我无法将参数传递到编译的脚本中。

ts-node --preserve-symlinks src/cli.ts -- printer:A
Run Code Online (Sandbox Code Playgroud)

这是行不通的。我在寻求帮助。

ts-node

13
推荐指数
3
解决办法
8354
查看次数

Flask-HttpAuth和Flask-Login

我正在创建一个小型REST服务.我正在寻找不同的身份验证方法.对于我使用模块Flask-Login的站点.看来是会话认证.Flask-HttpAuth模块提供了http和摘要认证方法.我有点困惑.他们互相补充吗?什么是最好的使用原因是什么?

谢谢.

authentication flask flask-login

10
推荐指数
2
解决办法
5959
查看次数

SQLAlchemy一对一关系,主要是外键

我将类映射到Drupal生成的现有MySQL表.我需要与表格(一对一)联系,但我遇到了问题.两个表的列nid.这两个字段都是主键.没有主键我无法定义外键.关系图不适用于主键.我的版本如下.

class Node(Base):
    __tablename__ = 'node'
    nid = Column(Integer, primary_key=True)
    vid = Column(Integer)
    uuid = Column(String(128))
    type = Column(String)

    field_data = relationship("NodeFieldData", order_by="NodeFieldData.nid", backref="node")

    def __repr__(self):
        return "<User(nid='%s', vid='%s', uuid='%s', type='%s')>" % (self.nid, self.vid, self.uuid, self.type)

class NodeFieldData(Base):
    __tablename__ = 'node_field_data'
    nid = Column(Integer, primary_key=True)
    type = Column(String, nullable=False)
    title = Column(String, nullable=False)
    #nid = Column(Integer, ForeignKey('Node.nid'))

    def __repr__(self):
        return "<User(nid='%s', vid='%s', uuid='%s', type='%s')>" % (self.nid, self.vid, self.uuid, self.type)
Run Code Online (Sandbox Code Playgroud)

谢谢.

python sqlalchemy one-to-one

6
推荐指数
1
解决办法
6189
查看次数

空对象引用上的“void com.getcapacitor.Bridge.onStart()”

我正在将 React 应用程序包装到 Capacitor 中。当我从 AndroidStudio 运行它时,应用程序会立即启动并停止。我收到以下信息。

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.app, PID: 20226
    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.getcapacitor.Bridge.onStart()' on a null object reference
        at com.getcapacitor.BridgeActivity.onStart(BridgeActivity.java:124)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1435)
        at android.app.Activity.performStart(Activity.java:8019)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3475)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Run Code Online (Sandbox Code Playgroud)

好像缺了什么。我检查了教程。@capacitor/core 存在。

capacitor

6
推荐指数
1
解决办法
339
查看次数

如何在 Flask-SqlAlchemy 中使用子查询?

query_1 = db\\\n    .Query([UserModel, func.count(FriendModel.friend_id)])\\\n    .select_from(UserModel)\\\n    .outerjoin(FriendModel, and_(UserModel.id==FriendModel.user_id))\\\n    .group_by(FriendModel.user_id)\n  s_1 = query_1.subquery(\'s_1\')\n  print s_1.c.id\n  query_2 = db\\\n    .Query(FriendModel)\\\n    .select_from(FriendModel)\\\n    .outerjoin(s_1, FriendModel.user_id==s_1.c.id)\n
Run Code Online (Sandbox Code Playgroud)\n\n

帮助将两个查询放在一起。\n https://gist.github.com/vlikin/17d53440eeef7f4147b2

\n\n
I receive such errors:\nInvalidRequestError: SQL expression, column, or mapped entity expected - got \'[<sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f2e28e1b810>, <sqlalchemy.sql.functions.count at 0x7f2e236c3ed0; count>]\'\n
Run Code Online (Sandbox Code Playgroud)\n\n

或者

\n\n
AttributeError: Neither \xe2\x80\x98count\xe2\x80\x99 object nor \xe2\x80\x98Comparator\xe2\x80\x99 object has an attribute \xe2\x80\x98_autoflush\xe2\x80\x99\n
Run Code Online (Sandbox Code Playgroud)\n\n

另外,由于 db.Query 而不是 db.session.query,我遇到了问题。我想使用 db.Query 因为它有分页:)

\n\n

谢谢。

\n

sqlalchemy subquery flask flask-sqlalchemy

5
推荐指数
1
解决办法
1715
查看次数

类型“ typeof @ types / d3 / index”上不存在属性“ tip”

我不能使用d3提示。

import * as d3 from "d3";
import  "d3-tip";

var tool_tip = d3.tip()
Run Code Online (Sandbox Code Playgroud)

我收到这样的错误。

Property 'tip' does not exist on type 'typeof "/home/viktor/projects/internet_trading_platform/client/node_modules/@types/d3/index"'.
Run Code Online (Sandbox Code Playgroud)

I have imported the d3 tip modules have to augment the d3 module. But it does not. According to https://www.typescriptlang.org/docs/handbook/declaration-merging.html

Regards.

The d3-tip declaration is located here https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/d3-tip/index.d.ts

d3.js typescript

5
推荐指数
1
解决办法
633
查看次数

$jsonSchema如何使用$ref

我正在使用 $jsonSchema 检查 mongo 层上的 json 模式验证。我需要定义一个多语言对象。我使用$ref。但我收到错误 - $jsonSchema 关键字“定义”当前不受支持根据文档,它必须具有常见的 json 模式行为。

 async install(): Promise<void> {
        let db = await this.dbContainer.getDb();
        let properties = _.fromPairs(this.config.languages.map((language) => {
           return  [language, {$ref: '#/definitions/post'}]
        }));
        await db.createCollection(
            this.collectionName,
            {
                validator: {
                    $jsonSchema: {
                        bsonType: 'object',
                        required: ['title', 'summary', 'link'],
                        definitions: {
                            post: {
                                title: {
                                    bsonType: 'string',
                                    description: 'Title is required'
                                },
                                summary: {
                                    bsonType: 'string',
                                    description: 'Summary is required'
                                },
                                href: {
                                    bsonType: 'string',
                                    description: 'Summary is required'
                                },
                            },
                        }, …
Run Code Online (Sandbox Code Playgroud)

validation jsonschema mongodb

3
推荐指数
1
解决办法
1433
查看次数

D3 TypeScript 将元素设置为路径元素的属性

我无法编译 TypeScript 代码。

 var line = d3.line()
      .x(function(d,i) {
        return x(i);
      })
      .y(function(d) {
        return y(d);
      });

    graph.append("path")
      .datum(data)
      .attr("class", "line")
      .attr("d", line); // < !!!!!-------
Run Code Online (Sandbox Code Playgroud)

我收到错误;

Argument of type 'Line<[number, number]>' is not assignable to parameter of type 'ValueFn<BaseType, number[], string | number | boolean>'.
  Types of parameters 'data' and 'datum' are incompatible.
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么办,因为 Line 类没有实现 ValueFn。我也没有看到针对这种情况的声明。

attr(name: string): string;
attr(name: string, value: null): this;
attr(name: string, value: string | number | boolean): this;

// element, in order, being …
Run Code Online (Sandbox Code Playgroud)

d3.js typescript

2
推荐指数
1
解决办法
2125
查看次数