예제 #1
0
def check_login(username, password):
    print(username, "  ", password)
    table = db.get_db()
    doc = table.find_one({"_id": username, "Password": password})
    if doc is None:
        return False
    else:
        return True
예제 #2
0
def register_user(userid, username, password, address, contact):
    new_user = {
        "_id": userid,
        "Name": username,
        "Password": password,
        "Contact": contact,
        "Address": address
    }
    print(new_user)
    table = db.get_db()
    x = table.insert_one(new_user)
    print(x.inserted_id)
예제 #3
0
def get_user(user_id):
    table = db.get_db()
    doc = table.find_one({'_id': user_id})
    return doc
예제 #4
0
import tests.User as user
import pymongo
import tests.db as db

table1 = db.get_db()


def get_user(user_id):
    table = db.get_db()
    doc = table.find_one({'_id': user_id})
    return doc


def insert_quote(title, quote, user_id):
    doc = table1.find_one({'_id': user_id})
    print(doc)
    if doc.get('Articles', None) is None:
        print(doc)
        table1.update_one({'_id': user_id}, {
            '$push': {
                'Articles': {
                    'article_id': 1,
                    'title': title,
                    'quote': quote
                }
            }
        })
    else:
        length = len(doc["Articles"])
        length += 1
        table1.update_one({'_id': user_id}, {