mongodb-rag-ingest
Version:
MongoDB Ingest CLI for the MongoDB Chatbot Framework.
34 lines • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeIngestMetaStore = void 0;
const mongodb_1 = require("mongodb-rag-core/mongodb");
/**
Creates a connection to ingest meta collection.
*/
const makeIngestMetaStore = ({ connectionUri, databaseName, entryId, }) => {
const client = new mongodb_1.MongoClient(connectionUri);
const collection = client
.db(databaseName)
.collection("ingest_meta");
return {
entryId,
async close() {
await client.close();
},
async loadLastSuccessfulRunDate() {
return ((await collection.findOne({ _id: entryId }))?.lastIngestDate ?? null);
},
async updateLastSuccessfulRunDate() {
await collection.updateOne({
_id: entryId,
}, {
$set: {
_id: entryId,
lastIngestDate: new Date(),
},
}, { upsert: true });
},
};
};
exports.makeIngestMetaStore = makeIngestMetaStore;
//# sourceMappingURL=IngestMetaStore.js.map