Closed EnOane closed 6 years ago
Hi EnOane, I'm assuming that your table name is "equipment" in equipment.json. Now, first is that the table structure should look something like this,
{
"equipment" : [
{
"row_name": "lala",
"id": "1525272872463",
"group": "oil",
.......
}
]
}
then you update the "lala" row by
const db = require('electron-db');
const electron = require('electron');
const app = electron.app || electron.remote.app;
let where = {
"row_name": "lala"
};
let set = {
"notes": "The things that you want to go in here.."
}
db.updateRow('equipment', where, set, (succ, msg) => {
// succ - boolean, tells if the call is successful
console.log("Success: " + succ);
console.log("Message: " + msg);
});
Thanks you. But I have another question. How I can get "row_name":
{ "equipment" : { "hope": { "row_name": "lala", "id": "1525272872463", "group": "oil" } }
WHat do you mean "How can u get "row_name"?
By the way, after the "equipment": it should be a list, square brackets instead of curly braces.
"squads": {
"firstSquad": {
"id": "1",
"name": "I смена",
"description": "THIS",
"rescues": [
{
"avatar": "/static/rescuers/10.jpg",
"name": "Бондарев Максим",
"birthday": "05/08/1984",
"position": "Командир отделения",
"dateOfEmployment": "01/02/2016",
"certificationForGRW": "01/02/2016",
"certificationForFW": "01/02/2016",
"certificationForSRW": "01/02/2016",
"certificationForHW": "1",
"certificationForHWM": "01/02/2016",
"docs": {
"passport": {
"name": "Паспорт",
"description": "Документ, удостоверящий личность",
"path": ""
},
"identityCardRescue": {
"name": "Удостоверение спасателя",
"description": "Выдается при первой аттестации",
"path": ""
},
"booksRescue": {
"name": "Книжка спасателя",
"description": "Выдается вместе с удостоверением",
"path": ""
}
}
},
]
} .....
How can I get "description"? Path = squads.firstSquad.description
At the current version of electron-db, you can't, based on the structure of your data.
At the moment, electron-db only support one level object. Which means only one object with the table name and that object contains a list of objects without any sub-level objects.
This is derived from the structure of a relational database where you can only have one level of fields in a table (e.g. "field1", "field2" etc.)
@alexiusacademia Thanks you very much! )
Thank you too for the question. That type of data structure on a database could considered in the future version of electron-db @EnOane
Hello.
How can I update row "lala" in electron-db, if I have this:
"equipment": { "lala" :{ "id": "1525272872463", "group": "oil", "name": "Мотопомпа «KLINER»", "inventory": "00-000005/69", "factory": "I205NZP", "release": "2012", "lifetime": "10", "verification": "02/06/2012", "dateOfVerification": "01/01/2020", "stock": "1", "timetable": "1", "notes": "" },