alexiusacademia / electron-db

Electron module that acts as database management and uses flat file database (json file) to store tables.
MIT License
87 stars 24 forks source link

"update" seems do not work well #8

Closed qianliuGit closed 6 years ago

qianliuGit commented 6 years ago

// 修改节点名称 ipc.on('renameNode', (event, arg) => { console.log('renameNode...') console.log('id: ' + arg.id) console.log('text: ' + arg.text)

let where = {
    'id': arg.id
}

let set = {
    'text': arg.text
}

db.updateRow(ORGTABELE, where, set, (succ, msg) => {
    console.log('update...')
    console.log('succ: ' + succ)
    console.log('msg: ' + msg)
})

})

------------------output --------------------------------

renameNode... id: 1528010777034 text: dfd update... succ: false msg: Cannot find the specified record. update... succ: false msg: Cannot find the specified record.

alexiusacademia commented 6 years ago

Hello qianliuGit, it looks that your implementation is right, however, based on the message displayed by the callback, there are 2 possible reasons for the error; one is that there are no matched keys or that the table structure is not according to the generated structure if you used electron-db on generating the rows.

Please tell me that you have data and structure to the json below: say your table name is "ORGTABELE"; ORGTABELE.json

{
  "ORGTABELE": [
    {
      "id": "1528010777034",
      "text": "Something else...",
      ...
    }
  ]
}
qianliuGit commented 6 years ago

Thanks a lot