@jnode/db 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ # Contributing to JNode packages
2
+
3
+ Hello there! Welcome to the contributing guildlines!
4
+
5
+ I was a bit surprised to see you here, especially since we’re not as well-known right now, and our packages are quite straightforward, mainly designed for specific projects.
6
+
7
+ If you’re here, perhaps you’ve spotted some bugs, security issues, or have an idea for something new. We’re happy to welcome any contributions!
8
+
9
+ - **Bugs**: If you find any bugs, please let us know.
10
+ - **Security Problems**: If a bug affects the package’s security, please reach out to JustApple via [email](mailto:ja@justapple.tw) or Discord!
11
+ - **Docs and Tutorials**: This is the part I’m most excited about. The docs are mostly generated by Gemini, so they might not be perfectly clear. Feel free to update them while maintaining the Node.js official doc style.
12
+
13
+ For new features, please always create an issue and wait for our response. Also, please remember to keep the package simple and free from third-party dependencies.
package/README.md CHANGED
@@ -265,6 +265,7 @@ Access these via `require('@jnode/db/dble')` or `dble.defaultDBLETypes`:
265
265
  - `DBLEStringField(maxLength, name, isKey, isRelative)`
266
266
  - `DBLEBufferField(maxLength, name, isKey, isRelative)`
267
267
  - `DBLEAnyField(length, name, isKey, isRelative)`
268
+ - `DBLEDateField(name, isKey, isRelative)`
268
269
 
269
270
  *Note: The `maxLength` argument is required for String and Buffer types to enforce DBLE's fixed-length binary schema standard.*
270
271
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jnode/db",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Simple database package for Node.js.",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/dble.js CHANGED
@@ -1009,6 +1009,26 @@ class DBLEAnyField extends DBLEField {
1009
1009
  }
1010
1010
  }
1011
1011
 
1012
+ // Date (8 Bytes in BigUInt64 ms)
1013
+ class DBLEDateField extends DBLEField {
1014
+ constructor(name, isKey, isRelative) {
1015
+ super(8, 'Date', name, isKey, isRelative);
1016
+ }
1017
+
1018
+ parse(buf, offset) {
1019
+ return new Date(Number(buf.readBigInt64LE(offset)));
1020
+ }
1021
+
1022
+ write(data, buf = Buffer.alloc(this.length), offset = 0) {
1023
+ buf.writeBigInt64LE(BigInt(data.getTime()), offset);
1024
+ return buf;
1025
+ }
1026
+
1027
+ default() {
1028
+ return new Date();
1029
+ }
1030
+ }
1031
+
1012
1032
  // dble default types
1013
1033
  const defaultDBLETypes = {
1014
1034
  Int8: DBLEInt8Field, i8: DBLEInt8Field,
@@ -1023,7 +1043,8 @@ const defaultDBLETypes = {
1023
1043
  Double: DBLEDoubleField, f64: DBLEDoubleField,
1024
1044
  String: DBLEStringField, str: DBLEStringField,
1025
1045
  Buffer: DBLEBufferField, buf: DBLEBufferField,
1026
- Any: DBLEAnyField, any: DBLEBufferField
1046
+ Any: DBLEAnyField, any: DBLEBufferField,
1047
+ Date: DBLEDateField, date: DBLEDateField
1027
1048
  };
1028
1049
 
1029
1050
  // export
@@ -1035,5 +1056,6 @@ module.exports = {
1035
1056
  DBLEFloatField, DBLEDoubleField,
1036
1057
  DBLEStringField, DBLEBufferField,
1037
1058
  DBLEAnyField,
1059
+ DBLEDateField,
1038
1060
  defaultDBLETypes
1039
1061
  };