Git Product home page Git Product logo

mongoose-state-machine's People

Contributors

dependabot[bot] avatar safer-bwd avatar

Stargazers

 avatar  avatar

Forkers

zsajidleo

mongoose-state-machine's Issues

Freeze state field

When trying to manually change a field with a state, throw an error like in javascript-state-machine.

status string becomes undefined inside Model.find() query, when immediately after creating an object for the Model which has state machine

const findOrderByStatus = (orderDetails) => {
  console.log('order details:', orderDetails); // printing orderStatus value which is 'requested'
  return Order.find({ orderDetails }); // but here orderDetails containing status becomes undefined value becomes undefined
};

output:
console.log: prints { orderStatus: 'requested', orderedBy: 5ed679dff46f02232fd5988a }
but while passed to Order.find the orderStatus changes to undefined like below:
Mongoose: Order.find({ orderStatus: undefined, orderedBy: ObjectId("5ed679dff46f02232fd5988a") }, { projection: {} })

State machine declaration

orderStatus: {
      type: Types.String,
      required: true,
    },

const stateMachine = { // state machines transitions and methods};

orderSchema.plugin(stateMachinePlugin, {
  fieldName: 'orderStatus',
  stateMachine,
});

This issue is occurring only when a new object is created for the model where the state machine is defined, once the server is restarted it is working properly it is able to pick 'registered', again when a new object is created again it becomes undefined, each and every time if the server is restarted after creating a new object, then only the find query is able to take the passed orderStatus string.

To confirm this is an issue with safer-bwd state machine, I tried querying with an attribute which is of non state machine, it is able to get the value passed to the query it is not undefined.

I appreciate if this issue is addressed immediately and help me out with proceeding with safer-bwd state machine.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.