Start a new topic

Anyway to change the _kmd.ect ?

Hi guys,


I am facing a challenge that my client need to save some record which was done on previous day due to workers absent or no internet connection. I tried the following before saving a new record but doesn't work and kinvey still save as current datetime.


                        KinveyMetaData meta = new KinveyMetaData();

                        meta.set("_kmd.ect", "2015-06-07T10:10:10.001Z");

                        meta.set("_kmd.lmt", "2015-06-07T10:10:10.002Z");


I am thinking create 1 more field but it is kind of duplicate record. appreciate any advice please.


Cheers,

Mark Thien


Mark,


Can't you just create the object then change the kmd field in the databrowser, or is this something you expect to have to do more often than that?  This is something you can handle through business logic as well.


Thanks,

yes this is pretty often that they need to back-dated some transaction. I tried to overwrite the _kmd.ect but it just doesn't work as after saving and I checked in Kinvey Databrowser, the _kmd.ect value is still the current datetime :

ProdProcess prodProcess = new ProdProcess();
KinveyMetaData meta = new KinveyMetaData();
meta.set("_kmd.ect", "2015-06-01T10:10:10.001Z");
meta.set("_kmd.lmt", "2015-06-01T10:10:10.002Z");
prodProcess.setAcl(acl);

kinveyClient.appData("prodprocess", ProdProcess.class).save(prodProcess, new KinveyClientCallback<ProdProcess>() {
                            @Override
                            public void onSuccess(ProdProcess result) {

                            }
});

 

Hi Mark,

The KMD object stands for "Kinvey metadata", and the ECT and LMT contained within it are intended to be the actual creation and modification time of the entity, and may be used for internal purposes. If you really want to modify them, you can do so using business logic. However, I would recommend that if you need to keep a date for your record which can be easily modified, simply create another field to represent the date of your transaction, i.e.:

 

 

{
	_id: ......,
	_kmd: {
		ect: ....,
		lmt: ....
	},
	transactionDate: ...
}

 

 

 You can then leave ect and lmt to be automatically updated, and modify transactionDate as you wish.

Login or Signup to post a comment