我正在创建一个可视化光纤网络的门户网站。 我正在使用连接在一起的光缆,以下模式表示连接:
var Splice = new Schema({
cable_a: String, //reference of cable_a
cable_b: String, //reference of cable_b
fibre_a: Number, //fibre of cable a
fibre_b: Number //fibre of cable b
});
我知道我的第一根电缆及其光纤的参考资料,我希望能够通过纤维光纤通过每个连接来重建电路的路径。关键是如果我的参考等于cable_a,cable_b成为我下一次研究的参考,直到我完成电路......
while ( //circuit not complete... ) {
Splice.find({$or: [{$and: [{cable_a:ref}, {fibre_a:fibre}]},{$and: [{cable_b:ref}, {fibre_b:fibre}]}]}, function(docs){
if ( ref == cable_a && f == fibre_a ) {
ref = cable_b;
f = fibre_b;
req.circuit.push(docs);
} else if ( ref == cable_a && f == fibre_a ) {
ref = cable_b;
f = fibre_b;
req.circuit.push(docs);
}
}
}
我希望有人可以帮助我。非常感谢。