bookshelf.js中的Knex.js方法

时间:2016-09-12 04:47:54

标签: bookshelf.js knex.js

如何在下面的代码中插入bookshelf.knex('articles').increment('fetchCount', 1)之类的router.get('/:id', (req, res) => { Article.query({ where: {id: req.params.id} }).fetch().then(article => { res.json(article) }) })

git am

我有一个名为'articles'的表,我想在发送json响应之前在fetchCount列中增加一个值。

当我使用bookshelf.knex时,书架应该是我的模型吗?

1 个答案:

答案 0 :(得分:2)

书架式方式如下:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 45, in <module>
    import numpy as np
  File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 14, in <module>
    from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString

重点是在获取和更新时都有事务,因此确保值被锁定并保持一致,直到更新。