---
# System prepended metadata

title: Abia

---

# Abia

![](https://i.imgur.com/rYJqLqK.png)

1. API endpoints
- GET simple.drive/id={parent_id}&cid={child_id}&access_token={access_token}
- POST simple.drive/download
    {
        parent_id: 12onme1mo,
        child_id: 23m1kj2m3,
        file_id: 1mk2l3m,
        key: "#{parent_id}-#{child_id}-#{file_id}"
    }
request param
response param

policy A file handle a controller A

Controller A << Base
def index
    response = GoogleDriveService.search(search_params)
end

Policy 
def index
    User.role == 'admin'
end

2. Database design, schema
- Users = id, name, address, role
- Directory = id, name, parent_id
1, Apples, 2
2, Fruits, nill
- File = id, name, directory_id, link


4. Models
Files belongs to Directory
parent_id -> id Directory
```
FOLDER STRUCTURE
Example
Fruits/
   Apples/
     - apple.txt
     - recipe.jpg
   Oranges/ 

Vegetables/
   Cucumber/
    - how_to_plant_cucumber.pdf
    
readme.txt
```
Requirements
- User can upload/download.
- User can navigate through the folders.


o Difference between database lock and transaction
Transaction
    insert to A -> success 
    insert to B -> failed
end

database indexing
User.where(parent_id: 1,phone_number: '+62')
indexing column (phone_number)
indexing column (parent_id, phone_number)