# -*- coding:utf-8 -*-

from Bmob import BmobSDK, BmobModel


APP_ID = "77b5dad35e17a087d679e62db9936950"
REST_API_KEY = "a9ab631355ce61f19be22f55a0b1b422"


class Course(BmobModel):

    name = ''
    score = 1.0


if __name__ == '__main__':
    # setup SDK
    Bmob.setup(APP_ID, REST_API_KEY)

    # Construct a Course instance and save it into bmob data service
    c1 = Course(name='xxx',score=4)
    c1.save()
    
    c2 = Course('957638ab1e')
    print("{0}:{1}".format(c2.name, c2.score))
    c2.age = c2.age + 1
    c2.save()


    print("The number of users: {0}".format(User().query().count()))
    for c in Course().query().w_regex('name', 'Program').orde("-createdAt").limit(20):
        print("%s,%s,%s" % (c.createAt, c.name, c.score))
    
    # query like a list
    q = Course().query().skip(5).limit(10)
    print("Items of q:")
    for c in q:
        print("\t%s" %s q.objectId)
    print("q.count(): %d" % q.count())
    print(q[-1].name)
    print(q[3:])

    # deleting operation
    print("The number before deleting: %d" % len(Course().query()))
    c1.delete()
    print("The number after deleting: %d" % len(Course().query()))




    



@@ -69,90 +69,90 @@
  = %22
-77b5dad35e17a087d679e62db9936950%22%0AREST_API_KEY = %22a9ab631355ce61f19be22f55a0b1b422
+3a3e06755ae2a0cc58ccc4747d9b7132%22%0AREST_API_KEY = %22b39628bf1e527ffb98527d471d314277
 %22%0A%0A%0A
@@ -157,21 +157,19 @@
 %0A%0Aclass 
-Cours
+Pag
 e(BmobMo
@@ -179,20 +179,23 @@
 ):%0A%0A    
-name
+page_id
  = ''%0A  
@@ -200,19 +200,34 @@
     
-score = 1.0
+article = %7B%7D%0A    tags = %5B%5D
 %0A%0A%0Ai
@@ -276,16 +276,19 @@
     Bmob
+SDK
 .setup(A
@@ -391,33 +391,82 @@
 1 = 
-Course(name='xxx',score=4
+Page(page_id='123',article=%7B%22id%22:%22hello%22,%22content%22:%22shabi%22%7D, tags=%5B'cifa'%5D
 )%0A  
@@ -495,26 +495,24 @@
 2 = 
-Course('957638ab1e
+Page('5269096a66
 ')%0A 
@@ -544,48 +544,67 @@
 (c2.
-name, c2.score))%0A    c2.age = c2.age + 1
+page_id, c2.article%5B'content'%5D))%0A    c2.content = %22updated%22
 %0A   
@@ -645,12 +645,12 @@
  of 
-user
+page
 s: %7B
@@ -664,12 +664,12 @@
 mat(
-User
+Page
 ().q
@@ -698,21 +698,19 @@
 or c in 
-Cours
+Pag
 e().quer
@@ -719,37 +719,34 @@
 ).w_
-regex('name', 'Program'
+in('tags', %5B'cifa'%5D
 ).orde
+r
 (%22-c
@@ -787,19 +787,16 @@
 t(%22%25s,%25s
-,%25s
 %22 %25 (c.c
@@ -804,28 +804,70 @@
 eate
+d
 At, c.
-name, c.score)
+page_id))%0A        print(c.tags)%0A        print(c.article
 )%0A  
@@ -901,21 +901,19 @@
     q = 
-Cours
+Pag
 e().quer
@@ -1001,11 +1001,10 @@
 s%22 %25
-s q
+ c
 .obj
@@ -1069,29 +1069,15 @@
 -1%5D.
-name)%0A    print(q%5B3:%5D
+page_id
 )%0A%0A 
@@ -1141,37 +1141,35 @@
 ting: %25d%22 %25 len(
-Cours
+Pag
 e().query()))%0A  
@@ -1230,21 +1230,19 @@
 %22 %25 len(
-Cours
+Pag
 e().quer

add test file