diff --git a/README.md b/README.md
index d683979..1a482e5 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@
-
+
## Introduction
@@ -27,7 +27,7 @@
Sharkitek is a Javascript / TypeScript library designed to ease development of client-side models.
With Sharkitek, you define the architecture of your models by specifying their properties and their types.
-Then, you can use the defined methods like `serialize`, `deserialize`, `save` or `serializeDiff`.
+Then, you can use the defined methods like `serialize`, `deserialize`, `patch` or `serializeDiff`.
```typescript
class Example extends s.model({
@@ -227,7 +227,7 @@ const result = model.serializeDiff();
// result = {}
```
-#### `save()`
+#### `patch()`
Get difference between original values and current ones, then reset it.
Similar to call `serializeDiff()` then `resetDiff()`.
@@ -246,7 +246,7 @@ const model = (new TestModel()).deserialize({
model.title = "A new title for a new world";
-const result = model.save();
+const result = model.patch();
// if `id` is defined as the model identifier:
// result = { id: 5, title: "A new title for a new world" }
// if `id` is not defined as the model identifier:
diff --git a/package.json b/package.json
index 23a9cdc..8e1478d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@sharkitek/core",
- "version": "3.2.2",
+ "version": "3.3.0",
"description": "TypeScript library for well-designed model architectures.",
"keywords": [
"deserialization",
diff --git a/src/Model/Model.ts b/src/Model/Model.ts
index 36b4daa..c9a3d2d 100644
--- a/src/Model/Model.ts
+++ b/src/Model/Model.ts
@@ -105,7 +105,7 @@ export interface ModelDefinition>;
+ patch(): Partial>;
}
/**
@@ -248,7 +248,7 @@ export function model>
+ patch(): Partial>
{
// Get the difference.
const diff = this.serializeDiff();
diff --git a/tests/Model.test.ts b/tests/Model.test.ts
index 03ecc63..fa83ab4 100644
--- a/tests/Model.test.ts
+++ b/tests/Model.test.ts
@@ -109,7 +109,7 @@ it("create and check state then serialize", () => {
});
-it("deserialize then save", () => {
+it("deserialize then patch", () => {
const article = (new Article()).deserialize({
id: 1,
title: "this is a test",
@@ -130,13 +130,13 @@ it("deserialize then save", () => {
expect(article.isDirty()).toBeTruthy();
- expect(article.save()).toStrictEqual({
+ expect(article.patch()).toStrictEqual({
id: 1,
text: "Modified text.",
});
});
-it("save with modified submodels", () => {
+it("patch with modified submodels", () => {
const article = (new Article()).deserialize({
id: 1,
title: "this is a test",
@@ -152,7 +152,7 @@ it("save with modified submodels", () => {
article.authors[0].name = "TEST";
article.authors[1].createdAt.setMonth(9);
- expect(article.save()).toStrictEqual({
+ expect(article.patch()).toStrictEqual({
id: 1,
authors: [
{ name: "TEST" },