Bug when copying Date object from one table to another
To reproduce
Run the following code to copy a complex datatype (e.g., Date) from one table to another:
import JSDB from '@small-tech/jsdb'
const db = JSDB.open('test')
db.a = {
x: new Date()
}
db.b = []
const x = db.a.x
db.b.push (x)
What should happen
It should work.
What actually happens
Error:
file:///home/aral/sandbox/jsdb-test/node_modules/@small-tech/jsdb/lib/JSDF.js:81
serialisedValue = `new Date('${value.toJSON()}')`
^
TypeError: this is not a Date object.
at Proxy.valueOf (<anonymous>)
at Proxy.[Symbol.toPrimitive] (<anonymous>)
at Proxy.toJSON (<anonymous>)
at Function.serialise (file:///home/aral/sandbox/jsdb-test/node_modules/@small-tech/jsdb/lib/JSDF.js:81:46)
at Function.serialise (file:///home/aral/sandbox/jsdb-test/node_modules/@small-tech/jsdb/lib/JSDF.js:63:30)
at DataProxy.setHandler (file:///home/aral/sandbox/jsdb-test/node_modules/@small-tech/jsdb/lib/DataProxy.js:117:25)
at Proxy.push (<anonymous>)
at file:///home/aral/sandbox/jsdb-test/index.js:6:6
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)