mongo_default_document.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. from taipy.common.config.common._validate_id import _validate_id
  12. class MongoDefaultDocument:
  13. """The default class for \"custom_document\" property to configure a `MongoCollectionDataNode^`.
  14. Attributes:
  15. **kwargs: Attributes of the MongoDefaultDocument object.
  16. Example:
  17. - `document = MongoDefaultDocument(name="example", age=30})`
  18. will return a MongoDefaultDocument object so that `document.name` returns `"example"`,
  19. and `document.age` returns `30`.
  20. - `document = MongoDefaultDocument(date="12/24/2018", temperature=20})`
  21. will return a MongoDefaultDocument object so that `document.date` returns `"12/24/2018"`,
  22. and `document.temperature` returns `20`.
  23. """
  24. def __init__(self, **kwargs):
  25. for attribute_name, value in kwargs.items():
  26. setattr(self, _validate_id(attribute_name), value)