대체 - 콜렉션 내에 이미 저장된 문서 변경

varcollectionName='people';// Documents will be located with their '_id' field // and replaced with the data in the 'json' field.vardocs=[{_id:1,json:{name:'carlitos',age:99}}];varoptions={// Mark data as dirty (true = yes, false = no), default true.markDirty:true};WL.JSONStore.get(collectionName).replace(docs,options).then(function(numberOfDocumentsReplaced){// Handle success.}).fail(function(errorObject){// Handle failure.});

보안 - 현재 사용자의 열려 있는 모든 콜렉션에 대한 액세스 닫기

보안 - 저장소에 액세스하는 데 사용되는 비밀번호 변경

// The password should be user input. // It is hard-coded in the example for brevity.varoldPassword='123';varnewPassword='456';varclearPasswords=function(){oldPassword=null;newPassword=null;};// Default username if none is passed is: 'jsonstore'.varusername='carlos';WL.JSONStore.changePassword(oldPassword,newPassword,username).then(function(){// Make sure you do not leave the password(s) in memory.clearPasswords();// Handle success.}).fail(function(errorObject){// Make sure you do not leave the password(s) in memory.clearPasswords();// Handle failure.});

푸시 - 더티로 표시되는 모든 문서를 가져오고 어댑터에 전송하고 정리된 것으로 표시

varcollectionName='people';vardirtyDocs;WL.JSONStore.get(collectionName).getAllDirty().then(function(arrayOfDirtyDocuments){// Handle getAllDirty success.dirtyDocs=arrayOfDirtyDocuments;varprocedure='procedure-name-1';varadapter='adapter-name';varresource=newWLResourceRequest("adapters/"+adapter+"/"+procedure,WLResourceRequest.GET);resource.setQueryParameter('params',[dirtyDocs]);returnresource.send();}).then(function(responseFromAdapter){// Handle invokeProcedure success.// You may want to check the response from the adapter// and decide whether or not to mark documents as clean.returnWL.JSONStore.get(collectionName).markClean(dirtyDocs);}).then(function(){// Handle markClean success.}).fail(function(errorObject){// Handle failure.});

가져오기 - 어댑터에서 새 데이터 가져오기

varcollectionName='people';varadapter='adapter-name';varprocedure='procedure-name-2';varresource=newWLResourceRequest("adapters/"+adapter+"/"+procedure,WLResourceRequest.GET);resource.send().then(function(responseFromAdapter){// Handle invokeProcedure success.// The following example assumes that the adapter returns an arrayOfData,// (which is not returned by default),// as part of the invocationResult object,// with the data that you want to add to the collection.vardata=responseFromAdapter.responseJSON// Example:// data = [{id: 1, ssn: '111-22-3333', name: 'carlos'}];varchangeOptions={// The following example assumes that 'id' and 'ssn' are search fields,// default will use all search fields// and are part of the data that is received.replaceCriteria:['id','ssn'],// Data that does not exist in the Collection will be added, default false.addNew:true,// Mark data as dirty (true = yes, false = no), default false.markDirty:false};returnWL.JSONStore.get(collectionName).change(data,changeOptions);}).then(function(){// Handle change success.}).fail(function(errorObject){// Handle failure.});

더티 문서 수 확인

콜렉션 제거

varcollectionName='people';WL.JSONStore.get(collectionName).removeCollection().then(function(){// Handle success.// Note: You must call the 'init' API to re-use the empty collection.// See the 'clear' API if you just want to remove all data that is inside.}).fail(function(errorObject){// Handle failure.});

콜렉션 내에 있는 모든 데이터 지우기

varcollectionName='people';WL.JSONStore.get(collectionName).clear().then(function(){// Handle success.// Note: You might want to use the 'removeCollection' API// instead if you want to change the search fields.}).fail(function(errorObject){// Handle failure.});

파일 정보 가져오기

like, rightLike, leftLike를 사용한 검색

// Match all records that contain the search string on both sides.// %searchString%vararr1=WL.JSONStore.QueryPart().like('name','ca');// returns {name: 'carlos', age: 10}vararr2=WL.JSONStore.QueryPart().like('name','los');// returns {name: 'carlos', age: 10}// Match all records that contain the search string on the left side and anything on the right side.// searchString%vararr1=WL.JSONStore.QueryPart().rightLike('name','ca');// returns {name: 'carlos', age: 10}vararr2=WL.JSONStore.QueryPart().rightLike('name','los');// returns nothing// Match all records that contain the search string on the right side and anything on the left side.// %searchStringvararr=WL.JSONStore.QueryPart().leftLike('name','ca');// returns nothingvararr2=WL.JSONStore.QueryPart().leftLike('name','los');// returns {name: 'carlos', age: 10}

iOS

초기화하고 연결 열기, 액세서 가져오기 및 데이터 추가

// Create the collections object that will be initialized.JSONStoreCollection*people=[[JSONStoreCollectionalloc]initWithName:@"people"];[peoplesetSearchField:@"name"withType:JSONStore_String];[peoplesetSearchField:@"age"withType:JSONStore_Integer];// Optional options object.JSONStoreOpenOptions*options=[JSONStoreOpenOptionsnew];[optionssetUsername:@"carlos"];//Optional username, default 'jsonstore'[optionssetPassword:@"123"];//Optional password, default no password// This object will point to an error if one occurs.NSError*error=nil;// Open the collections.[[JSONStoresharedInstance]openCollections:@[people]withOptions:optionserror:&error];// Add data to the collectionNSArray*data=@[@{@"name":@"carlos",@"age":@10}];intnewDocsAdded=[[peopleaddData:dataandMarkDirty:YESwithOptions:nilerror:&error]intValue];Initializewithasecurerandomtokenfromtheserver[WLSecurityUtilsgetRandomStringFromServerWithBytes:32timeout:1000completionHandler:^(NSURLResponse*response,NSData*data,NSError*connectionError){// You might want to see the response and the connection error// before moving forward.// Get the secure random string by using the data that is// returned from the generator on the server.NSString*secureRandom=[[NSStringalloc]initWithData:dataencoding:NSUTF8StringEncoding];JSONStoreCollection*ppl=[[JSONStoreCollectionalloc]initWithName:@"people"];[pplsetSearchField:@"name"withType:JSONStore_String];[pplsetSearchField:@"age"withType:JSONStore_Integer];// Optional options object.JSONStoreOptions*options=[JSONStoreOptionsnew];[optionssetUsername:@"carlos"];//Optional username, default 'jsonstore'[optionssetPassword:@"123"];//Optional password, default no password[optionssetSecureRandom:secureRandom];//Optional, default one will be generated locally// This points to an error if one occurs.NSError*error=nil;[[JSONStoresharedInstance]openCollections:@[ppl]withOptions:optionserror:&error];// Other JSONStore operations (e.g. add, remove, replace, etc.) go here.}];

대체 - 콜렉션 내에 이미 저장된 문서 변경

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// Find all documents that match the queries.NSArray*docs=@[@{@"_id":@1,@"json":@{@"name":@"carlitos",@"age":@99}}];// This object will point to an error if one occurs.NSError*error=nil;// Perform the replacement.intdocsReplaced=[[peoplereplaceDocuments:docsandMarkDirty:NOerror:&error]intValue];

제거 - 조회와 일치하는 문서 모두 삭제

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occurs.NSError*error=nil;// Find document with _id equal to 1 and remove it.intdocsRemoved=[[peopleremoveWithIds:@[@1]andMarkDirty:NOerror:&error]intValue];

계수 - 조회와 일치하는 총 문서 수 가져오기

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// Count all documents that match the query.// The default query is @{} which will// count every document in the collection.JSONStoreQueryPart*queryPart=[[JSONStoreQueryPartalloc]init];[queryPartsearchField:@"name"equal:@"carlos"];// This object will point to an error if one occurs.NSError*error=nil;// Perform the count.intcountResult=[[peoplecountWithQueryParts:@[queryPart]error:&error]intValue];

영구 삭제 - 모든 사용자의 데이터를 지우고 내부 스토리지를 영구 삭제하고 보안 아티팩트 지우기

// This object will point to an error if one occurs.NSError*error=nil;// Perform the destroy.[[JSONStoresharedInstance]destroyDataAndReturnError:&error];

보안 - 현재 사용자의 열려 있는 모든 콜렉션에 대한 액세스 닫기

// This object will point to an error if one occurs.NSError*error=nil;// Close access to all collections in the store.[[JSONStoresharedInstance]closeAllCollectionsAndReturnError:&error];

보안 - 저장소에 액세스하는 데 사용되는 비밀번호 변경

// The password should be user input.// It is hardcoded in the example for brevity.NSString*oldPassword=@"123";NSString*newPassword=@"456";NSString*username=@"carlos";// This object will point to an error if one occurs.NSError*error=nil;// Perform the change password operation.[[JSONStoresharedInstance]changeCurrentPassword:oldPasswordwithNewPassword:newPasswordforUsername:usernameerror:&error];// Remove the passwords from memory.oldPassword=nil;newPassword=nil;

푸시 - 더티로 표시되는 모든 문서를 가져오고 어댑터에 전송하고 정리된 것으로 표시

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occursNSError*error=nil;// Return all documents marked dirtyNSArray*dirtyDocs=[peopleallDirtyAndReturnError:&error];// ACTION REQUIRED: Handle the dirty documents here// (e.g. send them to an adapter).// Mark dirty documents as cleanintnumCleaned=[[peoplemarkDocumentsClean:dirtyDocserror:&error]intValue];

가져오기 - 어댑터에서 새 데이터 가져오기

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occurs.NSError*error=nil;// ACTION REQUIRED: Get data (e.g. Adapter).// For this example, it is hardcoded.NSArray*data=@[@{@"id":@1,@"ssn":@"111-22-3333",@"name":@"carlos"}];intnumChanged=[[peoplechangeData:datawithReplaceCriteria:@[@"id",@"ssn"]addNew:YESmarkDirty:NOerror:&error]intValue];

문서의 더티 여부 확인

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occurs.NSError*error=nil;// Check if document with _id '1' is dirty.BOOLisDirtyResult=[peopleisDirtyWithDocumentId:1error:&error];

더티 문서 수 확인

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occurs.NSError*error=nil;// Check if document with _id '1' is dirty.intdirtyDocsCount=[[peoplecountAllDirtyDocumentsWithError:&error]intValue];

콜렉션 제거

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occurs.NSError*error=nil;// Remove the collection.[peopleremoveCollectionWithError:&error];

콜렉션 내에 있는 모든 데이터 지우기

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// This object will point to an error if one occurs.NSError*error=nil;// Remove the collection.[peopleclearCollectionWithError:&error];

트랜잭션 시작, 일부 데이터 추가, 문서 제거, 트랜잭션 커미트 후 트랜잭션 롤백(실패한 경우)

// Get the accessor to an already initialized collection.JSONStoreCollection*people=[[JSONStoresharedInstance]getCollectionWithName:@"people"];// These objects will point to errors if they occur.NSError*error=nil;NSError*addError=nil;NSError*removeError=nil;// You can call every JSONStore API method inside a transaction except:// open, destroy, removeCollection and closeAll.[[JSONStoresharedInstance]startTransactionAndReturnError:&error];[peopleaddData:@[@{@"name":@"carlos"}]andMarkDirty:NOwithOptions:nilerror:&addError];[peopleremoveWithIds:@[@1]andMarkDirty:NOerror:&removeError];if(addError!=nil||removeError!=nil){// Return the store to the state before start transaction was called.[[JSONStoresharedInstance]rollbackTransactionAndReturnError:&error];}else{// Commit the transaction thus ensuring atomicity.[[JSONStoresharedInstance]commitTransactionAndReturnError:&error];}

파일 정보 가져오기

// This object will point to an error if one occursNSError*error=nil;// Returns information about files JSONStore uses to persist data.NSArray*results=[[JSONStoresharedInstance]fileInfoAndReturnError:&error];// => [{@"isEncrypted" : @(true), @"name" : @"carlos", @"size" : @3072}]

Android

초기화하고 연결 열기, 액세서 가져오기 및 데이터 추가

// Fill in the blank to get the Android application context.Contextctx=getContext();try{List<JSONStoreCollection>collections=newLinkedList<JSONStoreCollection>();// Create the collections object that will be initialized.JSONStoreCollectionpeopleCollection=newJSONStoreCollection("people");peopleCollection.setSearchField("name",SearchFieldType.STRING);peopleCollection.setSearchField("age",SearchFieldType.INTEGER);collections.add(peopleCollection);// Optional options object.JSONStoreInitOptionsinitOptions=newJSONStoreInitOptions();// Optional username, default 'jsonstore'.initOptions.setUsername("carlos");// Optional password, default no password.initOptions.setPassword("123");// Open the collection.WLJSONStore.getInstance(ctx).openCollections(collections,initOptions);// Add data to the collection.JSONObjectnewDocument=newJSONObject("{name: 'carlos', age: 10}");JSONStoreAddOptionsaddOptions=newJSONStoreAddOptions();addOptions.setMarkDirty(true);peopleCollection.addData(newDocument,addOptions);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations (init, add).throwex;}catch(JSONExceptionex){// Handle failure for any JSON parsing issues.throwex;}

서버의 보안 랜덤 토큰을 사용하여 초기화

// Fill in the blank to get the Android application context.Contextctx=getContext();// Do an AsyncTask because networking cannot occur inside the activity.AsyncTask<Context,Void,Void>aTask=newAsyncTask<Context,Void,Void>(){protectedVoiddoInBackground(Context...params){finalContextcontext=params[0];// Create the request listener that will have the// onSuccess and onFailure callbacks:WLRequestListenerlistener=newWLRequestListener(){publicvoidonFailure(WLFailResponsefailureResponse){// Handle Failure.}publicvoidonSuccess(WLResponseresponse){StringsecureRandom=response.getResponseText();try{List<JSONStoreCollection>collections=newLinkedList<JSONStoreCollection>();// Create the collections object that will be initialized.JSONStoreCollectionpeopleCollection=newJSONStoreCollection("people");peopleCollection.setSearchField("name",SearchFieldType.STRING);peopleCollection.setSearchField("age",SearchFieldType.INTEGER);collections.add(peopleCollection);// Optional options object.JSONStoreInitOptionsinitOptions=newJSONStoreInitOptions();// Optional username, default 'jsonstore'.initOptions.setUsername("carlos");// Optional password, default no password.initOptions.setPassword("123");initOptions.setSecureRandom(secureRandom);// Open the collection.WLJSONStore.getInstance(context).openCollections(collections,initOptions);// Other JSONStore operations (e.g. add, remove, replace, etc.) go here.}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations (init, add).ex.printStackTrace();}}};// Get the secure random from the server:// The length of the random string, in bytes (maximum is 64 bytes).intbyteLength=32;SecurityUtils.getRandomStringFromServer(byteLength,context,listener);returnnull;}};aTask.execute(ctx);

찾기 - 저장소 내에서 문서 찾기

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");JSONStoreQueryPartsfindQuery=newJSONStoreQueryParts();JSONStoreQueryPartpart=newJSONStoreQueryPart();part.addLike("name","carlos");part.addLessThan("age",99);findQuery.addQueryPart(part);// Add additional find options (optional).JSONStoreFindOptionsfindOptions=newJSONStoreFindOptions();// Returns a maximum of 10 documents, default no limit.findOptions.setLimit(10);// Skip 0 documents, default no offset.findOptions.setOffset(0);// Search fields to return, default: ['_id', 'json'].findOptions.addSearchFilter("_id");findOptions.addSearchFilter("json");// How to sort the returned values, default no sort.findOptions.sortBySearchFieldAscending("name");findOptions.sortBySeachFieldDescending("age");// Find documents that match the query.List<JSONObject>results=peopleCollection.findDocuments(findQuery,findOptions);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operationsthrowex;}

대체 - 콜렉션 내에 이미 저장된 문서 변경

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Documents will be located with their '_id' field //and replaced with the data in the 'json' field.JSONObjectreplaceDoc=newJSONObject("{_id: 1, json: {name: 'carlitos', age: 99}}");// Mark data as dirty (true = yes, false = no), default true.JSONStoreReplaceOptionsreplaceOptions=newJSONStoreReplaceOptions();replaceOptions.setMarkDirty(true);// Replace the document.peopleCollection.replaceDocument(replaceDoc,replaceOptions);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}

제거 - 조회와 일치하는 문서 모두 삭제

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Documents will be located with their '_id' field.intid=1;JSONStoreRemoveOptionsremoveOptions=newJSONStoreRemoveOptions();// Mark data as dirty (true = yes, false = no), default true.removeOptions.setMarkDirty(true);// Replace the document.peopleCollection.removeDocumentById(id,removeOptions);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operationsthrowex;}catch(JSONExceptionex){// Handle failure for any JSON parsing issues.throwex;}

계수 - 조회와 일치하는 총 문서 수 가져오기

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Count all documents that match the query.JSONStoreQueryPartscountQuery=newJSONStoreQueryParts();JSONStoreQueryPartpart=newJSONStoreQueryPart();// Exact match.part.addEqual("name","carlos");countQuery.addQueryPart(part);// Replace the document.intresultCount=peopleCollection.countDocuments(countQuery);JSONObjectdoc=peopleCollection.findDocumentById(resultCount);peopleCollection.replaceDocument(doc);}catch(JSONStoreExceptionex){throwex;}

영구 삭제 - 모든 사용자의 데이터를 지우고 내부 스토리지를 영구 삭제하고 보안 아티팩트 지우기

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Destroy the Store.WLJSONStore.getInstance(ctx).destroy();}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operationsthrowex;}

보안 - 현재 사용자의 열려 있는 모든 콜렉션에 대한 액세스 닫기

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Close access to all collections.WLJSONStore.getInstance(ctx).closeAll();}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}

보안 - 저장소에 액세스하는 데 사용되는 비밀번호 변경

// The password should be user input. // It is hard-coded in the example for brevity.Stringusername="carlos";StringoldPassword="123";StringnewPassword="456";// Fill in the blank to get the Android application context.Contextctx=getContext();try{WLJSONStore.getInstance(ctx).changePassword(oldPassword,newPassword,username);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}finally{// It is good practice to not leave passwords in memoryoldPassword=null;newPassword=null;}

푸시 - 더티로 표시되는 모든 문서를 가져오고 어댑터에 전송하고 정리된 것으로 표시

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Check if document with _id 3 is dirty.List<JSONObject>allDirtyDocuments=peopleCollection.findAllDirtyDocuments();// Handle the dirty documents here (e.g. calling an adapter).peopleCollection.markDocumentsClean(allDirtyDocuments);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operationsthrowex;}

가져오기 - 어댑터에서 새 데이터 가져오기

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Pull data here and place in newDocs. For this example, it is hard-coded.List<JSONObject>newDocs=newArrayList<JSONObject>();JSONObjectdoc=newJSONObject("{id: 1, ssn: '111-22-3333', name: 'carlos'}");newDocs.add(doc);JSONStoreChangeOptionschangeOptions=newJSONStoreChangeOptions();// Data that does not exist in the collection will be added, default false.changeOptions.setAddNew(true);// Mark data as dirty (true = yes, false = no), default false.changeOptions.setMarkDirty(true);// The following example assumes that 'id' and 'ssn' are search fields, // default will use all search fields// and are part of the data that is received.changeOptions.addSearchFieldToCriteria("id");changeOptions.addSearchFieldToCriteria("ssn");intchanged=peopleCollection.changeData(newDocs,changeOptions);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}catch(JSONExceptionex){// Handle failure for any JSON parsing issues.throwex;}

문서의 더티 여부 확인

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Check if document with id '3' is dirty.booleanisDirty=peopleCollection.isDocumentDirty(3);}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}

더티 문서 수 확인

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Get the count of all dirty documents in the people collection.inttotalDirty=peopleCollection.countAllDirtyDocuments();}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}

콜렉션 제거

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Remove the collection. The collection object is// no longer usable.peopleCollection.removeCollection();}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}

콜렉션 내에 있는 모든 데이터 지우기

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");// Clear the collection.peopleCollection.clearCollection();}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.throwex;}

트랜잭션 시작, 일부 데이터 추가, 문서 제거, 트랜잭션 커미트 후 트랜잭션 롤백(실패한 경우)

// Fill in the blank to get the Android application context.Contextctx=getContext();try{// Get the already initialized collection.JSONStoreCollectionpeopleCollection=WLJSONStore.getInstance(ctx).getCollectionByName("people");WLJSONStore.getInstance(ctx).startTransaction();JSONObjectdocToAdd=newJSONObject("{name: 'carlos', age: 99}");// Find documents that match query.peopleCollection.addData(docToAdd);//Remove added doc.intid=1;peopleCollection.removeDocumentById(id);WLJSONStore.getInstance(ctx).commitTransaction();}catch(JSONStoreExceptionex){// Handle failure for any of the previous JSONStore operations.// An exception occured. Take care of it to prevent further damage.WLJSONStore.getInstance(ctx).rollbackTransaction();throwex;}catch(JSONExceptionex){// Handle failure for any JSON parsing issues.// An exception occured. Take care of it to prevent further damage.WLJSONStore.getInstance(ctx).rollbackTransaction();throwex;}