Database Methods: Get Memory Info

Get memory information from the database.

🪶 This method returns the total size, the used size and the available size of the database in bytes or formatted.

1
  • import
  • MerlinDB
  • from
  • "@chrisaxxwell/merlin-db";
    2
  • //Or if you are using 'merlindb.min.js' just call 'new MerlinDB()';
  • 3
    4
  • const
  • merlin =
  • new
  • MerlinDB(
  • )
  • ;
    5
    6merlin
  • .getMemInfo(
  • )
  • .then(
  • e =>
  • {
  • 7   console
  • .log(
  • e
  • )
  • ;
    8
  • }
  • )
  • ;
    9
    10
  • //returns in bytes
  • 11
  • {
  • 12  
  • "total":
  • 32123321
  • ,
    13  
  • "used":
  • 33212
  • ,
    14  
  • "remainder":
  • 1233213
  • 15
  • }
  • If you want to format the values, use the options as a parameter


    format (kB | MB | GB): By default, MerlinDB returns all sizes in bytes.

    string (true | false): If you want to format the value to a string, set true.

    locale (String): Set the locale to format the string.
    1merlin
  • .getMemInfo(
  • {
  • 2  
  • format:
  • 'mb',
    3  
  • string:
  • true
  • ,
    4  
  • locale:
  • "pt-BR"
    5
  • }
  • )
  • .then(
  • e =>
  • {
  • 6   console
  • .log(
  • e
  • )
  • ;
    7
  • }
  • )
  • ;
    8
    9
  • //returns in megabytes formated
  • 10
  • {
  • 11  
  • "total":
  • "
  • 63
  • .
  • 047
  • ,
  • 74
  • MB",
    12  
  • "used":
  • "
  • 0
  • ,
  • 01
  • MB",
    13  
  • "remainder":
  • "
  • 63
  • .
  • 047
  • ,
  • 73
  • MB"
    14
  • }