0.1.0 • Published 10 months ago

rename-prop-mongo v0.1.0

Weekly downloads
-
License
CC-BY-ND-4.0
Repository
github
Last release
10 months ago

Rename Prop Mongo

Usage

This command searches for the most recently created document using the DATE_FIELD as the parameter to identify the newest document. It then renames the field specified by OLD_FIELD to the new name provided in NEW_FIELD.

The VALIDATION_FIELD is used to validate the document before renaming the field. If the document does not contain the VALIDATION_FIELD, the command will not rename the field.

To make the application work properly, you need to add the following environment variables to your .zshrc or .bashrc file:

import { renameFieldInLatestDocument } from "rename-prop-mongo";

await renameFieldInLatestDocument({
    MONGODB_URI: "mongodb://localhost:27017",
    DB_NAME: "test",
    COLLECTION_NAME: "test",
    DATE_FIELD: "date",
    OLD_FIELD: "old",
    NEW_FIELD: "new",
    VALIDATION_FIELD: "validation",
  });
export MONGODB_URI=mongodb://localhost:27017
export DB_NAME=db
export COLLECTION_NAME=myCollection
export DATE_FIELD=cratedAt
export OLD_FIELD=old
export NEW_FIELD=new
export VALIDATION_FIELD=_id

commandLine

  npx rename-prop-mongo@latest \
      -m "mongodb://localhost:27017" \
      -d "myDatabase" \
      -c "myCollection" \
      -f "createdAt" \
      -o "oldField" \
      -n "newField" \
      -v "_id"
 MONGODB_URI: The URI of your MongoDB database.
 DB_NAME: The name of the database you want to use.
 COLLECTION_NAME: The name of the collection you want to use.
 DATE_FIELD: The name of the field that contains the date when the document was created.
 OLD_FIELD: The name of the field you want to rename.
 NEW_FIELD: The new name you want to give to the field.
 VALIDATION_FIELD: The name of the field you want to use to validate the documents.

usage:

Make sure to replace localhost:27017 with the appropriate MongoDB URI if your database is hosted elsewhere.

0.1.0

10 months ago

0.0.22

10 months ago

0.0.21

10 months ago

0.0.19

10 months ago

0.0.18

10 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago