mongo_atlas_dataapi
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

mongo_atlas_dataapi

是对 mongodb Atlas Data API 接口的封装 官方文档

set_api_key

import mada from 'mongo_atlas_dataapi'
mada.set_api_key("Your data api key")

接口统一格式

/**
 * @example findOne
 * @param {{}} data - 请求数据,不同接口数据不同,参考文档
 * @param {string} collection - 要操作的集合
 * @param {string} [database=project] - 要操作的数据库, 默认值为project
 */
findOne(data, collection, database)

findOne

var res = await findOne({
    filter: { type: 'your-filter' }
}, 'your-collection')

var json = await res.json()
var data = json.document

find

var res = await find({
    filter: { type: 'your-filter' }
}, 'your-collection')

var json = await res.json()
var data = json.document

updateOne

// update
var updateRes = await updateOne({
    upsert: true,
    filter: {
        type: 'your-filter' 
    },
    update: {
        $inc: {
            count: 1
        }
    },
}, 'your collection', 'project')

json = await updateRes.json()
console.log('update result', json)

Readme

Keywords

Package Sidebar

Install

npm i mongo_atlas_dataapi

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

11.1 kB

Total Files

6

Last publish

Collaborators

  • easyfrog