Update doesn't seem to work, at least with plain javascript (not typescript)
Closed this issue ยท 8 comments
I'm using the example from the samples/simple, just with javascript instead of typescript. The docker image I'm using is postgres:15.3
When I run the application the 3 users do get inserted and the Cruella user gets deleted. The Anita user's age doesn't get updated though. I query the database and the age is still 25.
Here's my code:
import { endAllPools, pongoClient } from "@event-driven-io/pongo";
import { v4 as uuid } from "uuid";
const connectionString = "postgresql://casaos:casaos@192.168.1.177/casaos";
const pongo = pongoClient(connectionString);
const pongoDb = pongo.db();
const users = pongoDb.collection("users");
const roger = { name: "Roger", age: 30 };
const anita = { name: "Anita", age: 25 };
const cruella = { _id: uuid(), name: "Cruella", age: 40 };
await users.insertOne(roger);
await users.insertOne(cruella);
const { insertedId } = await users.insertOne(anita);
const anitaId = insertedId;
await users.updateOne({ _id: anitaId }, { $set: { age: 31 } });
await users.deleteOne({ _id: cruella._id });
const anitaFromDb = await users.findOne({ _id: anitaId });
console.log(anitaFromDb);
const usersUnder40 = await users.find({ age: { $lt: 40 } });
console.log(usersUnder40);
await endAllPools();
Thank you for giving the heads up. Which Pongo version are you using?
This scenario is covered in tests and they seem to be passing (see here:
) but maybe something else is happening or indeed JS transpilation messing somehow.I'm using version 0.2.3
Here's my package.json.
{
"name": "pongo-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@event-driven-io/pongo": "^0.2.3"
}
}
It's very likely that I'm not doing something correctly.
Great project by the way. I'm excited to be able to use this.
Okay, thank you. I was able to reproduce it. Also, in typescript, it sounds like my bad. :| I'll look into that.
Thank you for the kind words and the reproduce steps ๐
@vanillaike it appeared that it was my dumb mistake. See details in #23. I provided the fix and released 0.2.4
samples are also updated.
Again, thank you for understanding and sending information with reproduce steps ๐
@oskardudycz Thanks! I'll check it out.
@vanillaike, did it work? ๐
@oskardudycz Yes it did work! Thanks again.
@oskardudycz Yes it did work! Thanks again.
Great! Thank you for the feedback!