py4ai.data.layer.mongo.serializer module

Module for implementation of serializer objects for Mongo persistence layers.

class py4ai.data.layer.mongo.serializer.MongoModel(name, bases, dct)

Bases: ModelMetaclass

Class to convert pydantic model into MongoDB schema objects.

Create a MongoDB schema object.

Parameters
  • name – name of the class

  • bases – Bases for the class

  • dct – extra arguments

py4ai.data.layer.mongo.serializer.create_mongo_id(key: str) ObjectId

Create a MongoDB hash compatible key from a general string.

Parameters

key – input string to be converted to a Mongo compatible hash

Returns

MongoDB compatible ObjectId