Browse Source

chore: updates README.md

e22m4u 2 years ago
parent
commit
ae52f14fe7
1 changed files with 30 additions and 7 deletions
  1. 30 7
      README.md

+ 30 - 7
README.md

@@ -366,7 +366,7 @@ const result = await rep.patchById(24, data, {
   // документы (см. Связи)
   // документы (см. Связи)
   include: 'city',
   include: 'city',
   include: {city: 'country'},
   include: {city: 'country'},
-  include: ['city', 'airlines'],
+  include: ['city', 'companies'],
 });
 });
 ```
 ```
 
 
@@ -497,7 +497,7 @@ const result = await rep.find({
   // "include" - включить в результат связанные
   // "include" - включить в результат связанные
   // документы (см. Связи)
   // документы (см. Связи)
   include: 'author',
   include: 'author',
-  include: {author: 'city'},
+  include: {author: 'role'},
   include: ['author', 'categories'],
   include: ['author', 'categories'],
 });
 });
 ```
 ```
@@ -563,7 +563,7 @@ const result = await rep.findOne({
   // "include" - включить в результат связанные
   // "include" - включить в результат связанные
   // документы (см. Связи)
   // документы (см. Связи)
   include: 'author',
   include: 'author',
-  include: {author: 'city'},
+  include: {author: 'role'},
   include: ['author', 'categories'],
   include: ['author', 'categories'],
 });
 });
 ```
 ```
@@ -578,15 +578,18 @@ const result = await rep.findOne({
 // [
 // [
 //   {
 //   {
 //     "id": 1,
 //     "id": 1,
-//     "title": "The Forgotten Ship"
+//     "title": "The Forgotten Ship",
+//     "featured": true
 //   },
 //   },
 //   {
 //   {
 //     "id": 2,
 //     "id": 2,
-//     "title": "A Giant Bellows"
+//     "title": "A Giant Bellows",
+//     "featured": false
 //   },
 //   },
 //   {
 //   {
 //     "id": 3,
 //     "id": 3,
-//     "title": "Hundreds of bottles"
+//     "title": "Hundreds of bottles",
+//     "featured": false
 //   }
 //   }
 // ]
 // ]
 
 
@@ -596,10 +599,30 @@ const result = await rep.findById(2);
 console.log(result);
 console.log(result);
 // {
 // {
 //   "id": 2,
 //   "id": 2,
-//   "title": "A Giant Bellows"
+//   "title": "A Giant Bellows",
+//   "featured": false
 // }
 // }
 ```
 ```
 
 
+Использование параметра `filter`
+
+```js
+// второй параметр принимает объект настроек
+// возвращаемого результата (опционально)
+const result = await rep.findById(2, {
+  // "fields" - если определено, то результат
+  // будут включать только указанные поля
+  fields: 'title',
+  fields: ['title', 'featured'],
+
+  // "include" - включить в результат связанные
+  // документы (см. Связи)
+  include: 'author',
+  include: {author: 'role'},
+  include: ['author', 'categories'],
+});
+```
+
 #### delete(where = undefined)
 #### delete(where = undefined)
 
 
 Удаляет все документы коллекции или согласно условию. Возвращает количество
 Удаляет все документы коллекции или согласно условию. Возвращает количество