mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 07:31:33 +00:00
JSON.stringify params ipc send
This commit is contained in:
2
node_modules/db.js
generated
vendored
2
node_modules/db.js
generated
vendored
@@ -43,7 +43,7 @@ var db = {
|
||||
// 过时
|
||||
init: function () {
|
||||
var me = this;
|
||||
var dbNames = ['users', 'notebooks', 'notes', 'tags', 'images', 'attachs', 'noteHistories', 'g'];
|
||||
var dbNames = ['users', 'notebooks', 'notes', 'tags', /*'images',*/ 'attachs', 'noteHistories', 'g'];
|
||||
this.initIt(me, dbNames);
|
||||
},
|
||||
|
||||
|
12
node_modules/db_main.js
generated
vendored
12
node_modules/db_main.js
generated
vendored
@@ -51,6 +51,10 @@ db.exec = function(m, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.params && typeof m.params === 'string') {
|
||||
m.params = JSON.parse(m.params);
|
||||
}
|
||||
|
||||
if (m.method == 'find') {
|
||||
var params = m.params;
|
||||
var query = params.query;
|
||||
@@ -62,7 +66,7 @@ db.exec = function(m, callback) {
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
db.params = query;
|
||||
m.params = query;
|
||||
}
|
||||
}
|
||||
else if (m.method == 'update') {
|
||||
@@ -76,8 +80,14 @@ db.exec = function(m, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
// find 没有sorter
|
||||
// insert
|
||||
db[m.dbname][m.method](m.params, function (err, ret) {
|
||||
// console.log('返回结果');
|
||||
// console.log(m);
|
||||
// console.log(JSON.stringify(m.params));
|
||||
// console.log(err);
|
||||
// console.log(ret);
|
||||
// 返回结果
|
||||
callback({token: m.token, err: err, ret: ret});
|
||||
});
|
||||
|
5
node_modules/nedb_proxy.js
generated
vendored
5
node_modules/nedb_proxy.js
generated
vendored
@@ -33,7 +33,8 @@ DBProxy.prototype.send = function(params, callback, method) {
|
||||
token: token,
|
||||
method: method,
|
||||
dbname: this.dbname,
|
||||
params: params
|
||||
// 转为json字符串, 如果{[a], [a]}, 在main接收后变成了 {[a], [null]}, 对象引用问题
|
||||
params: params ? JSON.stringify(params) : ''
|
||||
}
|
||||
token2Callback[token] = callback;
|
||||
ipc.send('db-exec', m);
|
||||
@@ -43,6 +44,8 @@ DBProxy.prototype.send = function(params, callback, method) {
|
||||
// Notes.find(query).sort({'UpdatedTime': -1}).exec(function(err, notes) {
|
||||
DBProxy.prototype.find = function (params, callback) {
|
||||
if (callback) {
|
||||
// console.log('client');
|
||||
// console.log(params);
|
||||
this.send({query: params}, callback, 'find');
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user