xxxxxxxxxx
JavaScript (shell):
db.getCollectionNames()
Node.js:
db.listCollections()
xxxxxxxxxx
1. show collections; // Display all collections
2. show tables // Display all collections
3. db.getCollectionNames(); // Return array of collection. Example :[ "orders", "system.profile" ]
xxxxxxxxxx
<div className="lg:absolute right-0 lg:w-[200px]">
{form.watch('upload').length > 0 && (
<div className="centralize gap-1 p-2 bg-gray-100 border rounded-xl border-gray-200">
<LucideFileArchive size={18} />
<p className="text-center text-xs whitespace-nowrap">
{/* //truncate the file name if it is too long */}
{form.watch('upload')[0].name.length > 25
? `${form.watch('upload')[0].name.slice(0, 25)}...`
: form.watch('upload')[0].name}
</p>
</div>
)}
</div>
xxxxxxxxxx
useEffect(() => {
if (!selectedFile) return
let isCancelled = false
const uploadFile = async () => {
const totalSize = selectedFile.size
let uploadedSize = 0
// Calculate upload speed factor based on file size
const speedFactor = Math.max(1, totalSize / (50 * 1024 * 1024)) // Divide by 50MB to scale speed
// Adjust interval duration dynamically (smaller files upload faster)
const intervalDuration = Math.min(500, 500 * speedFactor)
const interval = setInterval(() => {
if (isCancelled) {
clearInterval(interval)
return
}
// Simulate upload progress
const increment = Math.min((1 / speedFactor) * totalSize * 0.05, totalSize - uploadedSize); // Adjusted progress
uploadedSize += increment; // Simulate 6% upload progress per interval
const progressPercentage = Math.min(
Math.ceil((uploadedSize / totalSize) * 100),
100
)
setProgress(progressPercentage)
if (progressPercentage === 100) {
clearInterval(interval)
handleUpload()
}
}, 500) // Update progress every 500ms
}
uploadFile()
return () => {
isCancelled = true
}
}, [selectedFile])