Giter VIP home page Giter VIP logo

awasomeunicloud's Introduction

目的

方便自己日常使用unicloud操作数据库和存储

适用于:uniapp开发小程序和H5,APP端未验证

云函数

  • cloudfunctions-aliyun\db\index.js 封装数据库操作函数,包括增删改查

函数

  • common.js 本地封装函数,暴露db,upload函数

调用方式

查询

querryData: async function() {
  // 从集合(users)查询(querry)所有记录
  const res = await this.common.db('querry', 'users')
  if (res) {
    this.users = res.result.data
  }
  // res.result.data为数据库真实数据
}

删除

removeData: async function(_id) {
  // 从集合(users)删除(remove)记录(doc)
  const res = await this.common.db('remove', 'users', {
    doc: _id
  })
}

增加

addDate: async function(e) {
  // e是表单传入数据
  // 增加(add)记录(data)到集合(users)
  const res = await this.common.db('add', 'users', {
    data: e.detail.value
  })
}

按条件查询

querryData: async function() {

  querryItem = {
    where = {
      name: 'abc'
    },
    order = ['addDate', 'asc']
    skip = 0
    limit = 10
    field = {
    '_id': true,
    'name': true
  	}
  }

  // 从集合(users)查询(querry)所有符合querryItem条件的记录
  const res = await this.common.db('querry', 'users', querryItem)
  if (res) {
    this.users = res.result.data
  }
  // res.result.data为数据库真实数据
}

awasomeunicloud's People

Contributors

qqyule avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

anchor10

awasomeunicloud's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.