Skip to content

Scoped Counters only working with a single reference_field #34

Open
@jpolvora

Description

@jpolvora

Given any model wich I want to scope by two reference_fields ['fieldA','fieldB'] this would give an error of mongo duplicate key.

const mongoose = require('mongoose'),
    Schema = mongoose.Schema;

const AutoIncrement = require('mongoose-sequence')(mongoose);

const schema = new Schema(
    {
        empresa: { type: Number, required: true },
        pedido: { type: Number, required: true },
        key: Number, //sequence
    });

schema.plugin(AutoIncrement, { id: 'items', inc_field: 'key', reference_fields: ['empresa','pedido'] });
´``

This bug can be reproduced with the latest 4.0.1 version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions