Product Overview
Features and Strengths
Use Cases
System Limits
const { data } = await models.post.create({data: {body: "Hello, World\\n\\nfrom china",title: "Hello, World",slug: "hello-world-cn",},});// Return the created post ID.console.log(data);// { id: "7d8ff72c665eb6c30243b6313aa8539e"}
const { data } = await models.post.createMany({data: [{title: "Hello World",},{title: "Hola Mundo ",},{title: "Hello, World",},{title: "Bonjour le Monde",},],});// Return the idList of the created article.console.log(data);// {// "idList": [// "7d8ff72c665ebe5c02442a1a7b29685e",// "7d8ff72c665ebe5c02442a1b77feba4b",// "7d8ff72c665ebe5c02442a1c48263dc6",// "7d8ff72c665ebe5c02442a1d53c311b0"// ]// }
const { data } = await models.post.update({data: {title: "Hello World",body: "Hello World",},filter: {where: {_id: {$eq: "xxxx", // It is recommended to pass the _id as data identifier for operations.},},},});// Return the number of successfully updated entries.console.log(data);// { count: 1}
const post = {title: "Hello World",body: "Hello World",_id: "foo",};const { data } = await models.post.upsert({create: post,update: post,filter: {where: {_id: {$eq: post._id,},},},});console.log(data);// Return when creating.// {// "count": 0,// "id": "foo"// }// Return when updating.// {// "count": 1,// "id": ""// }
const { data } = await models.post.updateMany({data: {slug: "hello-world",body: `"Hello World" can be translated into the following languages:English: Hello World Spanish: Hola Mundo French: Bonjour le Monde German: Hallo Welt Italian: Ciao Mondo Portuguese: Olá Mundo Dutch: Hallo Wereld Japanese: こんにちは、世界 (Konnichiwa, Sekai) Korean: 안녕하세요, 세계 (Annyeonghaseyo, Segye)},filter: {where: {title: {$nempty: 1, // Data that is not empty.},},},});// Return the number of successfully updated entries.console.log(data);// {// "count": 33// }
_id.const { data } = await models.post.delete({filter: {where: {_id: {$eq: "xxx", // It is recommended to pass the _id as the data identifier for operations.},},},});// Return the number of successfully deleted entries.console.log(data);// {// "count": 1// }
const { data } = await models.post.deleteMany({filter: {where: {title: {$eq: "Hello World",},},},});console.log(data);// Return the number of successfully deleted entries.// {// "count": 7// }
const { data } = await models.post.get({filter: {where: {_id: {$eq: _id, // It is recommended to pass the _id as data identifier for operations.},},},});// Return the queried data.console.log(data);// {// "owner": "Anonymous(95fblM7nvPi01yQmYxBvBg)",// "createdAt": 1717488585078,// "createBy": "Anonymous(95fblM7nvPi01yQmYxBvBg)",// "updateBy": "Anonymous(95fblM7nvPi01yQmYxBvBg)",// "_openid": "95fblM7nvPi01yQmYxBvBg",// "_id": "e2764d2d665ecbc9024b058f1d6b33a4",// "title": "Hello, World",// "body":"\\" Hello World\\"can be translated into the following languages: \\n\\n English: Hello World\\n Spanish: Hola Mundo\\n French: Bonjour le Monde\\n German: Hallo Welt\\n Italian: Ciao Mondo\\n Portugal: Olá Mundo\\n Dutch: Hallo Weeld\\n Japanese: , World (Konnichiwa, Sekai)\\n Korean: ,(Annyeonghaseyo, Segye)",// "slug": "hello-world",// "updatedAt": 1717490751944// }
records and the total count total will be returned.const { data } = await models.post.list({filter: {where: {},},getCount: true, // Enable to get total count.});// Return the queried data list `records` and the total count `total`.console.log(data);// {// "records": [// {// "owner": "Anonymous(95fblM7nvPi01yQmYxBvBg)",// "createdAt": 1717488585078,// "createBy": "Anonymous(95fblM7nvPi01yQmYxBvBg)",// "updateBy": "Anonymous(95fblM7nvPi01yQmYxBvBg)",// "_openid": "95fblM7nvPi01yQmYxBvBg",// "_id": "e2764d2d665ecbc9024b058f1d6b33a4",// "title": "Hello, World",// "body":"\\" Hello World\\"can be translated into the following languages: \\n\\n English: Hello World\\n Spanish: Hola Mundo\\n French: Bonjour le Monde\\n German: Hallo Welt\\n Italian: Ciao Mondo\\n Portugal: Olá Mundo\\n Dutch: Hallo Weeld\\n Japanese: , World (Konnichiwa, Sekai)\\n Korean: ,(Annyeonghaseyo, Segye)",// "slug": "hello-world",// "updatedAt": 1717490751944// },// {// ...// },// ],// "total": 51// }
피드백