Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConvertTo-LiteDbBSON failed to serialise '_id' in ObjectID type #24

Open
Mouth7505 opened this issue Nov 30, 2022 · 0 comments
Open

ConvertTo-LiteDbBSON failed to serialise '_id' in ObjectID type #24

Mouth7505 opened this issue Nov 30, 2022 · 0 comments

Comments

@Mouth7505
Copy link

Mouth7505 commented Nov 30, 2022

Description

I have an issue with $array | ConvertTo-LiteDbBSON -As Array, where the array items has _id in ObjectID type, ObjectID type is the default index type when the LiteDB is created by New-LiteDBCollection

Reference: LiteDB / Data Structure / Objectid (https://www.litedb.org/docs/data-structure/#objectid)

Expected Behavior

# 1. Connect to LiteDB, find some document, save to an variable
Open-LiteDbConnection -Database $DBPath -Credential $DBCred
$array = Find-LiteDBDocument -Collection $DBCollection -Limit 2

# Example values
array[0]
_id: 63802bc8ac6e08130fe7df92
name: Apple

# 2. Update an item in the array
$array[0].name = 'Banana'

# 3. Push update to DB
$array_BSON = $array | ConvertTo-LiteDbBSON -As Array
Update-LiteDBDocument -Collection $DBCollection -BsonDocumentArray $array_BSON

Actual Behavior

$array_BSON = $array | ConvertTo-LiteDbBSON -As Array
WARNING: Unable to convert value [[_id, {"Timestamp":1669344201,"Machine":11300360,"Pid":4879,"Increment":15227919,"CreationTime":"2022-11-25T02:43:21Z"}]] to datetime
  1. Update-LiteDBDocument does not throw warnings of _id not found
  2. DB not updated

Specifications

  • Version: PSLiteDB committed on 2022 Feb 13 (latest as of writing)
  • Platform: Powershell 7.3.0
  • Subsystem:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant