PeakDB
  • Introduction
  • Quick Start
  • Change Log
  • Reference
    • Bitwise Permission Flags
    • Supported Node.js Versions
    • NPM
    • GitHub
  • Constructors
    • Server
    • Connection
    • Collection
  • Classes
    • Collection
      • createBackup
      • loadBackup
      • drop
    • DocumentBasedCollection
      • insert
      • find
      • filter
      • has
      • update
      • archive
      • unarchive
      • delete
    • KeyValueBasedCollection
      • set
      • get
      • push
      • remove
      • find
      • filter
      • has
      • increase
      • decrease
      • delete
Powered by GitBook
On this page
  1. Constructors

Collection

The data is stored in collections, where how the collection is created and its detailed information are specified.

new Collection(options)

Create a collection where you can manage and store your data.

Parameter
Default
Description

options

options.name

options.type

options.id_length

32

options.indicate_created_at

false

options.indicate_created_timestamp

false

options.indicate_edited_at

false

options.indicate_edited_timestamp

false

options.indicate_archived_at

false

options.indicate_archived_timestamp

false

options.indicate_unarchived_at

false

options.indicate_unarchived_timestamp

false

options.save_timeout

1

options.save_directly_after

5

options.cache_retention_time

10

options.backup_retention_time

3

options.caching

false

options.auto_create_backup

false

options.detailed_debugger_logs

false

options.activate_drop_method

false

Example:

const example_collection = new <PeakDB | Connection>.Collection({
  "name": "EXAMPLE_COLLECTION",
  "type": "DOCUMENT_BASED",
  
  /*
    For document based collections
  */
  "id_length": 32,
  "indicate_created_at": false,
  "indicate_created_timestamp": true,
  "indicate_updated_at": false,
  "indicate_updated_timestamp": true,
  "indicate_archived_at": false,
  "indicate_archived_timestamp": true,
  "indicate_unarchived_at": false,
  "indicate_unarchived_timestamp": true,
  
  /*
    Can be used on all collection types
  */
  "save_timeout": 1,
  "save_directly_after": 5,
  "cache_retention_time": 10,
  "backup_retention_time": 3,
  "caching": true,
  "auto_create_backup": true,
  "detailed_debugger_logs": true,
  "activate_drop_method": false
});
PreviousConnectionNextCollection

Last updated 3 years ago

Collection options.

Name of collection.

[IMPORTANT] Type of the collection, which cannot be changed again later. Valid values: DOCUMENT_BASED, KEY_VALUE_BASED

(optional) [DOCUMENT-BASED COLLECTIONS] This determines the length of unique identities given to documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the creation date of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the creation timestamp of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the edited date of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the edited timestamp of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the archived at of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the archived timestamp of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the unarchived at of documents.

(optional) [DOCUMENT-BASED COLLECTIONS] Whether to specify the unarchived timestamp of documents.

(optional) This specifies how many seconds after a document is inserted, the collection will be saved. This way it limits the successive saving of the collection when many data are inserted in succession, so the system is not slowed down. Data loss may occur if the system is turned off after repeatedly entering data. When the document is added 5 times in a row, the collection is saved so that the data does not remain unsaved for a long time. This can be edited with the save_directly_after option.

(optional) This specifies that after how many documents have been inserted, the collection will be saved without the save timeout.

(optional) [If this value is -1, the cache is kept indefinitely] This specifies how many minutes the cache will be retained if caching is enabled. If there is no activity in the collection, the cache is cleared, thus preventing RAM loss.

(optional) [If this value is -1, backups will never be deleted] This determines after how many days the backups will be deleted.

(optional) [IMPORTANT] If this is enabled, the data is kept in the cache. In this case, the data is processed quickly, but the size of the collection is the loss of RAM. Is not preferred for large collections.

(optional) If this is enabled, this collection will create automatic backups.

(optional) If this is enabled, it will print more events in the collection to the console.

(optional) [IMPORTANT] If this is enabled, the <Collection>.Drop() method becomes operable. This command serves to drop your collection completely. It is a dangerous method.

Object
String
String
Number
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Number
Number
Number
Number
Boolean
Boolean
Boolean
Boolean