LokiJS 不允许 Json 数据插入
LokiJS not allowing Json data to insert
您好,我正在使用 cordova/angularjs/lokijs 以 json 格式在数据库中插入记录时显示类型错误("Document needs to be an object"),但在简单数组的情况下它的工作 fine.I需要按要求存储为 JSON。
任何帮助家伙
谢谢
查看 LokiJS 的 insert
代码:
var docs = Array.isArray(doc) ? doc : [doc];
var results = [];
docs.forEach(function (d) {
if (typeof d !== 'object') {
throw new TypeError('Document needs to be an object');
}
其中 doc
是传递给 insert
方法的原始对象,如果 doc
不是对象 LokiJS 将抛出错误。确保传递给 insert 的参数是一个 JS 对象,typeof
语句应该确认这一点。
您好,我正在使用 cordova/angularjs/lokijs 以 json 格式在数据库中插入记录时显示类型错误("Document needs to be an object"),但在简单数组的情况下它的工作 fine.I需要按要求存储为 JSON。 任何帮助家伙 谢谢
查看 LokiJS 的 insert
代码:
var docs = Array.isArray(doc) ? doc : [doc];
var results = [];
docs.forEach(function (d) {
if (typeof d !== 'object') {
throw new TypeError('Document needs to be an object');
}
其中 doc
是传递给 insert
方法的原始对象,如果 doc
不是对象 LokiJS 将抛出错误。确保传递给 insert 的参数是一个 JS 对象,typeof
语句应该确认这一点。