All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.1.13.0.1-move-api.js Maven / Gradle / Ivy

There is a newer version: 4.5.2
Show newest version
print("\n\Move API reference into the subscription.");

db.subscriptions.find().forEach(
    function (subscription) {
        var plan = db.plans.findOne({'_id': subscription.plan});
        if (plan !== null) {
            if (subscription.api) {
                print("Subscription id["+subscription._id+"] already associated to an API. Skipping.");
            } else {
                db.subscriptions.updateOne(
                    {_id: subscription._id},
                    {
                      $set:
                        {
                          api: plan.apis[0],
                        }
                    },
                    {upsert: false}
                  );
            }
        } else {
            print('No plan for subscription: id[' + subscription._id + '] plan[' + subscription.plan + ']')
        }
    }
);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy