0.1.0 • Published 1 year ago

rename-prop-mongo v0.1.0

Weekly downloads
-
License
CC-BY-ND-4.0
Repository
github
Last release
1 year 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

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago