Skip to content

Instantly share code, notes, and snippets.

@rikkimax
Created April 16, 2014 10:58
Show Gist options
  • Save rikkimax/10852537 to your computer and use it in GitHub Desktop.
Save rikkimax/10852537 to your computer and use it in GitHub Desktop.
var Books3 = Class({
constructor: function(_id, edition) {
this._id = _id === undefined ? "" : _id;
this.edition = Number(edition === undefined ? "0" : edition);
},
save: function() {
var this_ = this;
new Ajax.Request("/.svc/Books3/" + this._id, {
method: "POST",
parameters: {
_id: this_._id
},
onSuccess: function(event) {
onSaveOfObject(this_, event);
},
onFailure: function(event) {
onFailureToSaveObject(this_, event);
}
});
},
remove: function() {
var this_ = this;
new Ajax.Request("/.svc/Books3/" + this._id, {
method: "DELETE",
onSuccess: function(event) {
onDeleteOfObject(this_, event);
},
onFailure: function(event) {
onFailureToDeleteObject(this_, event);
}
});
}
});
Books3.prototype.findOne = function(_id) {
var ret = new Ajax.Request("/.svc/Books3/" + _id, {
method: "GET",
asynchronous: false
});
ret = ret.responseJSON();
return new Books3(ret._id);
};
Books3.prototype.query = function() {
return {
props: {
_id_eq: undefined,
_id_neq: undefined,
_id_lt: undefined,
_id_lte: undefined,
_id_mt: undefined,
_id_mte: undefined,
_id_like: undefined,
edition_eq: undefined,
edition_neq: undefined,
edition_lt: undefined,
edition_lte: undefined,
edition_mt: undefined,
edition_mte: undefined,
edition_like: undefined
},
offset: undefined,
maxAmount: undefined,
find: function () {
this_ = this;
var ret = new Ajax.Request("/.svc/Books3/", {
method: "POST",
parameters: {
_id_eq: this_.props._id_eq,
_id_neq: this_.props._id_neq,
_id_lt: this_.props._id_lt,
_id_lte: this_.props._id_lte,
_id_mt: this_.props._id_mt,
_id_mte: this_.props._id_mte,
_id_like: this_.props._id_like,
edition_eq: this_.props.edition_eq,
edition_neq: this_.props.edition_neq,
edition_lt: this_.props.edition_lt,
edition_lte: this_.props.edition_lte,
edition_mt: this_.props.edition_mt,
edition_mte: this_.props.edition_mte,
edition_like: this_.props.edition_like,
__offset: this_.offset,
__maxAmount: this_.maxAmount
},
onSuccess: function (event) {
},
onFailure: function (event) {
}
});
ret = ret.responseJSON();
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment