Open zzswang opened 5 years ago
Modal.sort() without arguments will throw error.
const Vehicle = Nohm.model("YourModelName", {
properties: {
ns: { type: "string", index: true },
line: { type: "string", index: true },
modelBrief: { type: "string", index: true },
},
methods: {},
client,
});
await Vehicle.sort();
error
Invalid field in YourModelName.sort() options: 'undefined'
Yep, you are right. It's a problem with the .id =
thing I suggested to you in the other issue (#140).
The "idsets" sets are not filled this way. I thought there was a test covering this, but apparently there isn't.
I will try to fix it in the coming days, alternatively PRs are welcome. :-)
The problem is that here it doesn't properly check for numIdExiting vs create cases and then if that were to be fixed, the create method would need to take an optional id. Since this could lead to confusing behavior I would like to add a model configuration option "manualId" or something like that, so that usecases like yours are covered properly without affecting normal id creation scenarios.
The methods affected by this bug are: find
, sort
and exists
.
In the documents, it says:
But I've tried with following code:
The out put is an emtpy array.
If we put a param like
const vs = await Vehicle.find({ ns: "/second" });
, then it works.