Thursday, 21 July 2022

CRUD OPerations

 These are examples for CRUD OPerations


var oModel = this.getView().getModel();

Create Operation
====================================================================
var oPayload = {
"name":"name";
};


            oModel.create("/SampleSet", oPayload, {
method: "POST",
success: function (oData, oResponse) {

},
error: function (error, resp) {

}
});

Update  Operation
====================================================================

var oPayload = {
"name":"name";
};
var sPath =  "/SampleSet(SampleNumber='2084093745')";
oModel.update(sPath, oPayload{
method: "PUT",
success: function () {

},
error: function (oError) {

}
});



Read operation
====================================================================
var oName = "Raj"
var aFilter = [
new sap.ui.model.filter({"Name","EQ",oName})];
oModel.read("/sampleSet", {
filters: aFilter,
success: function (oData) {

},
error: function (oError) {

}
});

Delete Operation
====================================================================

var sPath =  "/SampleSet(SampleNumber='2084093745')";
oModel.remove(sPath, {
success: function () {

},
error: function (oError) {

}
});



Read operation
====================================================================
var oName = "Raj"
var aFilter = [
new sap.ui.model.filter({"Name","EQ",oName})];
oModel.read("/sampleSet", {
filters: aFilter,
success: function (oData) {

},
error: function (oError) {

}
});

Delete Operation
====================================================================

var sPath =  "/SampleSet(SampleNumber='2084093745')";
oModel.remove(sPath, {
success: function () {

},
error: function (oError) {

}
});


test ganaral binding(testing )

  /home/user/projects/project1/webapp/model/record.json: {     "text" : "outer text" ,     "myrecorsd" : [    ...