Coder Social home page Coder Social logo

document-db's Introduction

DocsDB-I2

DB setup

Connect to database client = DB.Connection()

Create database client.create_db('dbname')

Create collection client.dbname.create_collection('collname')

CRUD operations

Insert client.dbname.collname.insert(JSON document(s))

Delete - to delete documents based on condition
client.dbname.collname.indexdelete(condition JSON document)
Use 'and'/'or' to make multiple conditions and combine
Ex: {"$or": [{"name": "sam"},{"age":{"$eq": 24}}]}, {"$and": [{"name": "sam"},{"age":{"$eq": 24}}]}

Update - to update documents based on condition and update to be made
client.dbname.collname.update(condition JSON document, update to be made)
Ex: client.db1.abc.update({"name": "ryan"},{"$rename": {"agee": "age"}, "$set": {"age":25}})

readSpecific - read/query all or some documents in a collection
client.dbname.collname.readSpecific(projection JSON document, condition JSON document)
Projection document to choose which fields to return
Condition document to specify matching conditions
Projection document example: {attr1 : 1, attr3: 1}
Condition document example: {"salary":{"$gt": 1000}}
Example: client.db1.abc.readSpecific('{"$project": {"name": 0, "age": 1}}','{"age": {"$gt": 29}}') Example: client.db2.col2.indexedreadSpecific({},{}) to read all documents with all attributes in collection

Indexes

Create Secondary Indexes - client.db2.col2.createSecondaryIndex(<attribute>, <branching-factor: usually 200>)

indexedreadSpecific - to make the database build and use B+ tree indexes
Example: client.db1.abc.indexedreadSpecific('{"$project": {"name": 0, "age": 1}}','{"age": {"$gt": 29}}')
Builds indexes on attributes in conditional document

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.