Get Paginated Documents
POST
/database/get-paginated-documents
Request
Query Params
`<button class
string
optional
Example:
"btn btn-sm btn-secondary" onclick="dms.viewCollectionDocs('${dbName}', '${colName}', ${page - 1})"> 上一页 </button>` : ''} ${total > page * 20 ? `<button class="btn btn-sm btn-secondary ms-2" onclick="dms.viewCollectionDocs('${dbName}', '${colName}', ${page + 1})"> 下一页 </button>` : ''} </div> `); } catch (error) { this.showToast('获取文档失败', 'danger'); } } // 新增集合创建方法 async createCollection(dbName) { const colName = prompt('请输入新集合名称:'); if (!colName) return; try { await this.fetchAPI(`create-collection/${dbName}`, { body: JSON.stringify({ name: colName }) }); this.showToast(`集合 ${colName} 创建成功`, 'success'); this.fetchCollections(); } catch (error) { this.showToast(`创建失败: ${error.message}`, 'danger'); } } // 完善通用API请求方法(强制POST) async fetchAPI(endpoint, options = {}) { try { const response = await fetch(`${this.API_BASES[this.currentEnv]}${endpoint}`, { method: 'POST', // 强制使用POST方法 headers: { 'X-Api-Key': this.API_KEY, 'Authorization': `Basic ${btoa(`admin:${this.validPassword}`)}`, 'Content-Type': 'application/json' }, body: options.body || null, ...options }); if (!response.ok) { const errorText = await response.text(); throw new Error(`[${response.status}] ${errorText}`); } return response.json(); } catch (error) { this.showToast(`请求失败: ${error.message}`, 'danger'); throw error; } } // 新增通用信息弹窗 showInfoModal(content) { const modal = document.createElement('div'); modal.className = 'modal fade'; modal.innerHTML = ` <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header bg-primary text-white"> <h5 class="modal-title">详细信息</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <div class="modal-body"> ${content} </div> </div> </div> `; document.body.appendChild(modal); new bootstrap.Modal(modal).show(); } // 新增字节格式化方法 formatBytes(bytes) { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }
Header Params
X-Master-Key
string
optional
Example:
{{master_key}}
X-Access-Token
string
optional
Body Params application/json
Request samples
Responses
Modified at 2025-02-26 19:32:30