小编Ale*_*dro的帖子

Repo.insert 返回预加载的关联?

Repo.insert(changeset)
Run Code Online (Sandbox Code Playgroud)

返回{:ok, struct},但 struct 没有预加载的关联。我是否被迫选择查询来预加载其关联?或者我可以以某种方式避免无用的查询吗?

elixir ecto phoenix-framework repo

6
推荐指数
0
解决办法
2312
查看次数

从具有条件的循环中将项添加到列表中

我正在尝试将一些项添加到列表中,但仅在条件为真时才添加.我的函数实际上是在条件为假时存储空数据.

hit_list = for {_mob, %{id: id}} <- get_mob_list(state.mobs) do
  if condition do
    id
  end
end
Run Code Online (Sandbox Code Playgroud)

输出:

[null, "2"]
Run Code Online (Sandbox Code Playgroud)

elixir

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

在循环中增加整数

我试图仅在某些条件下增加变量

Enum.reduce(items, 0, fn item, acc  ->
  if item.condition do
    acc = acc+1
    Logger.info acc
  end
end)
Run Code Online (Sandbox Code Playgroud)

但我明白了

** (ArithmeticError) bad argument in arithmetic expression
Run Code Online (Sandbox Code Playgroud)

loops elixir

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

在 Elixir 中通过内部映射值查找键

让我们假设我有:

%{apple: %{color: red, id: 1}, pear: %{color: green, id: 2}}

按值循环获取密钥(例如苹果)的最快方法是什么(例如,颜色:红色)

elixir

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

Python3 Odoo TypeError sys.print 不是函数

我刚刚安装了 Odoo 的全新安装(没有自定义插件/模块),在创建数据库后,我在主页上收到此错误:


The style compilation failed, see the error below. Your recent actions may be the cause, please try reverting the changes you made.

(b'', b'TypeError: sys.print is not a function
    at /usr/lib/nodejs/less/bin/lessc:384:25
    at tree.importVisitor.finish [as _finish] (/usr/lib/nodejs/less/lib/less/parser.js:669:28)
    at tree.importVisitor.run (/usr/lib/nodejs/less/lib/less/import-visitor.js:25:22)
    at Object.parse (/usr/lib/nodejs/less/lib/less/parser.js:675:22)
    at parseLessFile (/usr/lib/nodejs/less/bin/lessc:345:12)
    at Socket. (/usr/lib/nodejs/less/bin/lessc:407:9)
    at Socket.emit (events.js:228:7)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
')This error occured while compiling the bundle 'web.assets_common' containing:
    - /web/static/lib/bootstrap/less/variables.less
    ....
Run Code Online (Sandbox Code Playgroud)

经过谷歌的一些研究后,我已经尝试过:

  • 将nodejs链接到/usr/bin中的节点

  • 重新安装node-js、less-js、uglify-js

  • 重新安装所有 pip3 Odoo 要求

  • 每次尝试后都会删除我的数据库 …

python less node.js odoo

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

标签 统计

elixir ×4

ecto ×1

less ×1

loops ×1

node.js ×1

odoo ×1

phoenix-framework ×1

python ×1

repo ×1