简体   繁体   English

MobileFirst JSONStore在模拟器上按预期工作,但在iOS设备上失败

[英]MobileFirst JSONStore working as intended on emulator, but failing on ios device

I have the following lines of code to add some variables to a local collection: 我有以下几行代码可将一些变量添加到本地集合中:

var data = {
    name: '123',
    brand: '123',
    model: '123',
    img: 'imgurl',
    category: '123',
    segment: 'Recreational',
    pilotFstName: '123',
    pilotLstName: '123',
    insuranceNumber: '123',
    insNumber2: '123',
    extras: '123',
    hasCamera: '123',
    insuranceDate: '123'
};

var collectionName = 'Drones';
var options = {};

WL.JSONStore.get(collectionName)
    .add(data, options)

.then(function(numberOfDocumentsAdded) {
    //handle success
    alert("Done");
})

.fail(function(errorObject) {
    //handle failure
    alert(errorObject);
});

This works fine working in a browser, but fails with an INVALID_SEARCH_FIELD error in any iOS physical device. 在浏览器中可以正常工作,但是在任何iOS物理设备中均会出现INVALID_SEARCH_FIELD错误。 This is the full error stack in Xcode. 这是Xcode中的完整错误堆栈。

[JSONStoreCollection findWithQueryParts:andOptions:error:] in JSONStoreCollection.m:603 :: Error: JSON_STORE_INVALID_SEARCH_FIELD, code: 22, collection name: Drones, accessor username: jsonstore, currentQuery: (null), JSONStoreQueryOptions: [JSONStoreQueryOptions: sort=( { identifier = desc; } ) filter=(null), limit=1, offset=(null)] JSONStoreCollection.m:603中的[JSONStoreCollection findWithQueryParts:andOptions:error:]:错误:JSON_STORE_INVALID_SEARCH_FIELD,代码:22,集合名称:无人机,访问者用户名:jsonstore,currentQuery :(空),JSONStoreQueryOptions:[JSONStoreQueryOptions:sort =({标识符= desc;})filter =(null),limit = 1,offset =(null)]

My Collections.js : 我的Collections.js:

function getCollections(){

    return {

        Account : {
            searchFields: {
                userName:"string",
                password:"string",
                frstName:"string",
                lstName:"string",
                mail:"string"
                }
        },  
        Drones : {
            searchFields: {
                name:"string",
                brand:"string",
                model:"string",
                img:"string",
                category:"string",
                segment:"string",
                pilotFstName:"string",
                pilotLstName:"string",
                insuranceNumber:"string",
                insNumber2:"string",
                extras:"string",
                hasCamera:"string",
                insuranceDate:"string"              
                }



        },
        Historial : {
            searchFields: {
                name:"string",
                date:"string",
                posXStart:"string",
                PosYStart:"string",
                PosXFinish:"string",
                PosYFinish:"string"         
            }



        }

    };
};
(function () {

    WL.JSONStore.init(getCollections(), {
        // password : 'PleaseChangeThisPassword'
    })

    .then(function () {
        WL.Logger.debug(['All collections were loaded successfully'].join('\n'));
    })

    .fail(function (errObj) {
        WL.Logger.ctx({pretty: true}).error(errObj);
    });

}()); 

I had to create the collection since you did not mention it in your code snippet. 我必须创建集合,因为您没有在代码片段中提及它。
I also had to first initialize the JSONStore. 我还必须首先初始化JSONStore。

The following code works for me both in browser and iOS Simulator (that pretty much means also on a physical device in most cases such as this one): 以下代码在浏览器和iOS Simulator中都对我有效(在大多数情况下,这在物理设备上也是如此):

main.js: main.js:

var collectionName = 'myCollectionObject';

var collections = {
    myCollectionObject : {
        searchFields : {
            name: 'string', 
            brand: 'string',
            model: 'string',
            img: 'string',
            category: 'string',
            segment: 'string',
            pilotFstName: 'string',
            pilotLstName: 'string',
            insuranceNumber: 'string',
            insNumber2: 'string',
            extras: 'string',
            hasCamera: 'string',
            insuranceDate: 'string'
        }
    }
};

var data = [{
    name: '123',
    brand: '123',
    model: '123',
    img: 'imgurl',
    category: '123',
    segment: 'Recreational',
    pilotFstName: '123',
    pilotLstName: '123',
    insuranceNumber: '123',
    insNumber2: '123',
    extras: '123',
    hasCamera: '123',
    insuranceDate: '123'
}];

var options = {};
var addOptions = { };

function wlCommonInit(){
    WL.JSONStore.init(collections, options)

    .then(function () {
      return WL.JSONStore.get(collectionName).add(data, addOptions);
    })

    .then(function (numberOfDocumentsAdded) {
      alert ("success: " + numberOfDocumentsAdded);
    })

    .fail(function (errorObject) {
        alert ("failure: " + errorObject);
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS:UIDeviceOrientation 未按预期工作 - iOS: UIDeviceOrientation is not working as intended iOS 7 supportedInterfaceOrientation未按预期工作 - iOS 7 supportedInterfaceOrientation not working as intended ios 通用重定向链接不适用于真实设备,但适用于模拟器 - ios universal redirection link is not working on real device, but working on emulator 如何将MobileFirst CLI应用程序部署到IOS设备? - How to deploy MobileFirst CLI application to an IOS device? jQuery不能在实际的IOS设备上使用Cordova 3.1.0,但可以在模拟器上使用 - JQuery Not working Cordova 3.1.0 on actual IOS device but works on emulator 升级到iOS 9和MobileFirst 7.1后无法登录设备或模拟器上的应用程序 - Unable to login to app on device or simulator after upgrade to iOS 9 and MobileFirst 7.1 MobileFirst 8迁移:如何在iOS中生成相同的设备UUID - MobileFirst 8 Migration : How to generate same device UUID in iOS 如何在 MobileFirst 服务器适配器中获取 iOS 设备 ID? - How to get iOS device ID in MobileFirst server adapter? 无法登录iOS实际设备MobileFirst Project上的应用 - Cannot login to app on iOS actural Device MobileFirst Project iOS 9 应用程序链接在 URL 缩短时无法按预期工作 - iOS 9 App links not working as intended with URL Shorterning
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM