Applet development using the cloud encountered a problem where a query

When I want with a small cloud development program where the query, the results no matter what the input is not being given, she did not pay attention, but later found some of the data entered into a database, to print out the query is successful, there is no data entered into the database, will get a collection, but the length of this set is 0 only. This matter can not be reused fail, and should be used to determine the length of data.length length of zero means that does not contain

 DB.where(
      {
        code:code
      }
    ).get({
      success(res) {
         if (res.data.length == 0) {
          console.log ( "query data failed", res)
          that.setData({     
            options : 3,                
          })
        }
        // console.log ( "query data success", res.data [0])
        // console.log ( "query data success", res.data.length)
          that.setData({
          name : res.data[0].name,
          age : res.data[0].age,        
          options : true,                
        })   
      }
    })

Guess you like

Origin www.cnblogs.com/myfighting/p/12299905.html