2018年12月

$model->save()的时候,如果不符合rules,会导致保存失败,但不抛出异常,所以这个时候,就需要看一下是不是rules设置的问题,所以可以这样做:

$model->save(false)

这样做,就是绕过了rules里对数据的validation,首先保证了,你对数据库的CRUD是成功的,代码是OK的,然后再看,是否是数据的问题。

Statements That Cannot Be Rolled Back

Some statements cannot be rolled back. In general, these include data definition language (DDL) statements, such as those that create or drop databases, those that create, drop, or alter tables or stored routines.

You should design your transactions not to include such statements. If you issue a statement early in a transaction that cannot be rolled back, and then another statement later fails, the full effect of the transaction cannot be rolled back in such cases by issuing a ROLLBACK statement.

这个是摘自MySQL文档,8.0和5.7都是同样的文档。但据说PostgreSQL没有这样的问题,还没测试。

我理解就是,tag就是一个快照(snapshot),是某个repo的一个定点的状态;branch就是一段录像,反应了一段时间范围内的变化(多个commit组成了一个开发变化的过程)。

A tag represents a version of a particular branch at a moment in time. A branch represents a separate thread of development that may run concurrently with other development efforts on the same code base. Changes to a branch may eventually be merged back into another branch to unify them.

From the theoretical point of view:

  • tags are symbolic names for a given revision. They always point to the same object (usually: to the same revision); they do not change.
  • branches are symbolic names for line of development. New commits are created on top of branch. The branch pointer naturally advances, pointing to newer and newer commits.

- 阅读剩余部分 -

云计算的优点真的不用再多讲,但就没缺点了吗?当然有。

比如,我最近在使用Netlify Identity,这个服务的一个最大的有点非常OK的,但缺点也很明显嘛,因为有一个在localStorage里,有一个key/value键值对,key是gotrue.user,value是一个多层嵌套的json字符串,那么由于多层嵌套,一不小心就会报错,比如忘记序列化、忘记把字符串再解析为json等。

更重要的是,这条key/value记录,CRUD等操作都是由Netlify Identity Widget来操作,这就违背了store的一个重要理念:single source of truth。那么这怎么办?

- 阅读剩余部分 -

key/value里,value只能是string,不能是json等,必须做处理,比如JSON.stringify(),取出来再做JSON.parse()

比如在setItem的时候,用window.localStorage.setItem("localVar", JSON.stringify(obj)),取出来的时候,用JSON.parse(window.localStorage.getItem("localVar"))

其实问题出在哪里呢?

我在用Nelitfy Identity这个云服务,很好,但是,最后localStorage里,存储的是一个很大的东西,这个解析之后是嵌套了好几层的json,就是json套json,每次都一不小心都报错。

所以我现在的情况是不管了,把这个user获取到之后,重新搞一个userprofile json,只有一层,没有其他东西,解析起来也很方便。