@keyv/mongo 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/216ebf05-ecde-4f49-891b-59762203bcc0.json +1 -0
- package/.nyc_output/6cdae809-9b2c-44f0-b9c2-41555a0e2af9.json +1 -0
- package/.nyc_output/processinfo/216ebf05-ecde-4f49-891b-59762203bcc0.json +1 -0
- package/.nyc_output/processinfo/6cdae809-9b2c-44f0-b9c2-41555a0e2af9.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/README.md +3 -3
- package/package.json +58 -58
- package/src/index.js +222 -30
- package/test/test.js +124 -6
- package/.github/workflows/build.yaml +0 -30
- package/LICENSE +0 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/src/index.js":{"path":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/src/index.js","statementMap":{"0":{"start":{"line":3,"column":21},"end":{"line":3,"column":38}},"1":{"start":{"line":4,"column":15},"end":{"line":4,"column":39}},"2":{"start":{"line":5,"column":20},"end":{"line":5,"column":50}},"3":{"start":{"line":6,"column":21},"end":{"line":6,"column":52}},"4":{"start":{"line":7,"column":13},"end":{"line":7,"column":28}},"5":{"start":{"line":9,"column":22},"end":{"line":9,"column":113}},"6":{"start":{"line":12,"column":2},"end":{"line":12,"column":10}},"7":{"start":{"line":13,"column":2},"end":{"line":13,"column":26}},"8":{"start":{"line":14,"column":2},"end":{"line":14,"column":18}},"9":{"start":{"line":15,"column":2},"end":{"line":17,"column":3}},"10":{"start":{"line":16,"column":3},"end":{"line":16,"column":17}},"11":{"start":{"line":19,"column":2},"end":{"line":21,"column":3}},"12":{"start":{"line":20,"column":3},"end":{"line":20,"column":46}},"13":{"start":{"line":23,"column":2},"end":{"line":30,"column":4}},"14":{"start":{"line":32,"column":23},"end":{"line":36,"column":3}},"15":{"start":{"line":34,"column":13},"end":{"line":34,"column":34}},"16":{"start":{"line":38,"column":2},"end":{"line":42,"column":4}},"17":{"start":{"line":40,"column":13},"end":{"line":40,"column":33}},"18":{"start":{"line":45,"column":2},"end":{"line":115,"column":5}},"19":{"start":{"line":46,"column":3},"end":{"line":114,"column":7}},"20":{"start":{"line":48,"column":5},"end":{"line":50,"column":6}},"21":{"start":{"line":49,"column":6},"end":{"line":49,"column":39}},"22":{"start":{"line":52,"column":5},"end":{"line":52,"column":39}},"23":{"start":{"line":53,"column":5},"end":{"line":113,"column":6}},"24":{"start":{"line":54,"column":6},"end":{"line":57,"column":9}},"25":{"start":{"line":58,"column":6},"end":{"line":58,"column":71}},"26":{"start":{"line":59,"column":6},"end":{"line":61,"column":9}},"27":{"start":{"line":62,"column":6},"end":{"line":64,"column":9}},"28":{"start":{"line":65,"column":6},"end":{"line":67,"column":9}},"29":{"start":{"line":68,"column":6},"end":{"line":70,"column":9}},"30":{"start":{"line":72,"column":6},"end":{"line":76,"column":7}},"31":{"start":{"line":75,"column":7},"end":{"line":75,"column":70}},"32":{"start":{"line":78,"column":6},"end":{"line":83,"column":7}},"33":{"start":{"line":82,"column":7},"end":{"line":82,"column":73}},"34":{"start":{"line":85,"column":6},"end":{"line":85,"column":71}},"35":{"start":{"line":87,"column":6},"end":{"line":87,"column":60}},"36":{"start":{"line":88,"column":6},"end":{"line":94,"column":8}},"37":{"start":{"line":95,"column":6},"end":{"line":101,"column":8}},"38":{"start":{"line":103,"column":6},"end":{"line":110,"column":7}},"39":{"start":{"line":109,"column":7},"end":{"line":109,"column":70}},"40":{"start":{"line":112,"column":6},"end":{"line":112,"column":26}},"41":{"start":{"line":119,"column":2},"end":{"line":144,"column":3}},"42":{"start":{"line":120,"column":3},"end":{"line":143,"column":6}},"43":{"start":{"line":121,"column":4},"end":{"line":127,"column":7}},"44":{"start":{"line":129,"column":19},"end":{"line":129,"column":62}},"45":{"start":{"line":130,"column":4},"end":{"line":142,"column":7}},"46":{"start":{"line":131,"column":16},"end":{"line":131,"column":18}},"47":{"start":{"line":132,"column":5},"end":{"line":132,"column":41}},"48":{"start":{"line":132,"column":30},"end":{"line":132,"column":39}},"49":{"start":{"line":134,"column":5},"end":{"line":137,"column":8}},"50":{"start":{"line":135,"column":6},"end":{"line":135,"column":51}},"51":{"start":{"line":136,"column":6},"end":{"line":136,"column":20}},"52":{"start":{"line":139,"column":5},"end":{"line":141,"column":8}},"53":{"start":{"line":140,"column":6},"end":{"line":140,"column":23}},"54":{"start":{"line":146,"column":2},"end":{"line":154,"column":4}},"55":{"start":{"line":147,"column":3},"end":{"line":153,"column":5}},"56":{"start":{"line":148,"column":4},"end":{"line":150,"column":5}},"57":{"start":{"line":149,"column":5},"end":{"line":149,"column":22}},"58":{"start":{"line":152,"column":4},"end":{"line":152,"column":21}},"59":{"start":{"line":158,"column":20},"end":{"line":158,"column":79}},"60":{"start":{"line":160,"column":2},"end":{"line":176,"column":3}},"61":{"start":{"line":161,"column":3},"end":{"line":175,"column":6}},"62":{"start":{"line":162,"column":19},"end":{"line":167,"column":6}},"63":{"start":{"line":169,"column":4},"end":{"line":174,"column":7}},"64":{"start":{"line":170,"column":5},"end":{"line":172,"column":8}},"65":{"start":{"line":171,"column":6},"end":{"line":171,"column":22}},"66":{"start":{"line":173,"column":5},"end":{"line":173,"column":23}},"67":{"start":{"line":178,"column":2},"end":{"line":184,"column":4}},"68":{"start":{"line":179,"column":3},"end":{"line":183,"column":4}},"69":{"start":{"line":188,"column":2},"end":{"line":190,"column":3}},"70":{"start":{"line":189,"column":3},"end":{"line":189,"column":33}},"71":{"start":{"line":192,"column":2},"end":{"line":202,"column":3}},"72":{"start":{"line":193,"column":3},"end":{"line":201,"column":6}},"73":{"start":{"line":194,"column":23},"end":{"line":194,"column":32}},"74":{"start":{"line":195,"column":19},"end":{"line":197,"column":6}},"75":{"start":{"line":198,"column":4},"end":{"line":200,"column":25}},"76":{"start":{"line":199,"column":20},"end":{"line":199,"column":71}},"77":{"start":{"line":199,"column":66},"end":{"line":199,"column":70}},"78":{"start":{"line":200,"column":18},"end":{"line":200,"column":23}},"79":{"start":{"line":204,"column":2},"end":{"line":208,"column":4}},"80":{"start":{"line":205,"column":3},"end":{"line":207,"column":44}},"81":{"start":{"line":207,"column":20},"end":{"line":207,"column":43}},"82":{"start":{"line":212,"column":2},"end":{"line":214,"column":3}},"83":{"start":{"line":213,"column":3},"end":{"line":213,"column":82}},"84":{"start":{"line":213,"column":38},"end":{"line":213,"column":80}},"85":{"start":{"line":213,"column":70},"end":{"line":213,"column":79}},"86":{"start":{"line":216,"column":2},"end":{"line":222,"column":4}},"87":{"start":{"line":217,"column":3},"end":{"line":221,"column":26}},"88":{"start":{"line":221,"column":16},"end":{"line":221,"column":25}},"89":{"start":{"line":226,"column":2},"end":{"line":228,"column":3}},"90":{"start":{"line":227,"column":3},"end":{"line":227,"column":16}},"91":{"start":{"line":230,"column":2},"end":{"line":242,"column":5}},"92":{"start":{"line":231,"column":22},"end":{"line":231,"column":31}},"93":{"start":{"line":232,"column":18},"end":{"line":234,"column":5}},"94":{"start":{"line":236,"column":3},"end":{"line":241,"column":114}},"95":{"start":{"line":241,"column":26},"end":{"line":241,"column":112}},"96":{"start":{"line":241,"column":63},"end":{"line":241,"column":93}},"97":{"start":{"line":241,"column":107},"end":{"line":241,"column":111}},"98":{"start":{"line":246,"column":2},"end":{"line":248,"column":3}},"99":{"start":{"line":247,"column":3},"end":{"line":247,"column":16}},"100":{"start":{"line":250,"column":2},"end":{"line":262,"column":5}},"101":{"start":{"line":251,"column":22},"end":{"line":251,"column":31}},"102":{"start":{"line":252,"column":18},"end":{"line":254,"column":5}},"103":{"start":{"line":256,"column":3},"end":{"line":261,"column":124}},"104":{"start":{"line":261,"column":31},"end":{"line":261,"column":122}},"105":{"start":{"line":261,"column":73},"end":{"line":261,"column":103}},"106":{"start":{"line":261,"column":117},"end":{"line":261,"column":121}},"107":{"start":{"line":266,"column":0},"end":{"line":266,"column":27}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":11,"column":1},"end":{"line":11,"column":2}},"loc":{"start":{"line":11,"column":27},"end":{"line":116,"column":2}},"line":11},"1":{"name":"(anonymous_1)","decl":{"start":{"line":34,"column":4},"end":{"line":34,"column":5}},"loc":{"start":{"line":34,"column":13},"end":{"line":34,"column":34}},"line":34},"2":{"name":"(anonymous_2)","decl":{"start":{"line":40,"column":4},"end":{"line":40,"column":5}},"loc":{"start":{"line":40,"column":13},"end":{"line":40,"column":33}},"line":40},"3":{"name":"(anonymous_3)","decl":{"start":{"line":45,"column":29},"end":{"line":45,"column":30}},"loc":{"start":{"line":45,"column":40},"end":{"line":115,"column":3}},"line":45},"4":{"name":"(anonymous_4)","decl":{"start":{"line":47,"column":6},"end":{"line":47,"column":7}},"loc":{"start":{"line":47,"column":25},"end":{"line":114,"column":5}},"line":47},"5":{"name":"(anonymous_5)","decl":{"start":{"line":118,"column":1},"end":{"line":118,"column":2}},"loc":{"start":{"line":118,"column":10},"end":{"line":155,"column":2}},"line":118},"6":{"name":"(anonymous_6)","decl":{"start":{"line":120,"column":28},"end":{"line":120,"column":29}},"loc":{"start":{"line":120,"column":38},"end":{"line":143,"column":4}},"line":120},"7":{"name":"(anonymous_7)","decl":{"start":{"line":130,"column":23},"end":{"line":130,"column":24}},"loc":{"start":{"line":130,"column":34},"end":{"line":142,"column":5}},"line":130},"8":{"name":"(anonymous_8)","decl":{"start":{"line":132,"column":24},"end":{"line":132,"column":25}},"loc":{"start":{"line":132,"column":30},"end":{"line":132,"column":39}},"line":132},"9":{"name":"(anonymous_9)","decl":{"start":{"line":134,"column":22},"end":{"line":134,"column":23}},"loc":{"start":{"line":134,"column":28},"end":{"line":137,"column":6}},"line":134},"10":{"name":"(anonymous_10)","decl":{"start":{"line":139,"column":23},"end":{"line":139,"column":24}},"loc":{"start":{"line":139,"column":32},"end":{"line":141,"column":6}},"line":139},"11":{"name":"(anonymous_11)","decl":{"start":{"line":146,"column":27},"end":{"line":146,"column":28}},"loc":{"start":{"line":147,"column":3},"end":{"line":153,"column":5}},"line":147},"12":{"name":"(anonymous_12)","decl":{"start":{"line":147,"column":45},"end":{"line":147,"column":46}},"loc":{"start":{"line":147,"column":52},"end":{"line":153,"column":4}},"line":147},"13":{"name":"(anonymous_13)","decl":{"start":{"line":157,"column":1},"end":{"line":157,"column":2}},"loc":{"start":{"line":157,"column":22},"end":{"line":185,"column":2}},"line":157},"14":{"name":"(anonymous_14)","decl":{"start":{"line":161,"column":28},"end":{"line":161,"column":29}},"loc":{"start":{"line":161,"column":38},"end":{"line":175,"column":4}},"line":161},"15":{"name":"(anonymous_15)","decl":{"start":{"line":169,"column":23},"end":{"line":169,"column":24}},"loc":{"start":{"line":169,"column":34},"end":{"line":174,"column":5}},"line":169},"16":{"name":"(anonymous_16)","decl":{"start":{"line":170,"column":25},"end":{"line":170,"column":26}},"loc":{"start":{"line":170,"column":31},"end":{"line":172,"column":6}},"line":170},"17":{"name":"(anonymous_17)","decl":{"start":{"line":178,"column":27},"end":{"line":178,"column":28}},"loc":{"start":{"line":179,"column":3},"end":{"line":183,"column":4}},"line":179},"18":{"name":"(anonymous_18)","decl":{"start":{"line":187,"column":1},"end":{"line":187,"column":2}},"loc":{"start":{"line":187,"column":13},"end":{"line":209,"column":2}},"line":187},"19":{"name":"(anonymous_19)","decl":{"start":{"line":193,"column":28},"end":{"line":193,"column":29}},"loc":{"start":{"line":193,"column":38},"end":{"line":201,"column":4}},"line":193},"20":{"name":"(anonymous_20)","decl":{"start":{"line":199,"column":11},"end":{"line":199,"column":12}},"loc":{"start":{"line":199,"column":20},"end":{"line":199,"column":71}},"line":199},"21":{"name":"(anonymous_21)","decl":{"start":{"line":199,"column":60},"end":{"line":199,"column":61}},"loc":{"start":{"line":199,"column":66},"end":{"line":199,"column":70}},"line":199},"22":{"name":"(anonymous_22)","decl":{"start":{"line":200,"column":12},"end":{"line":200,"column":13}},"loc":{"start":{"line":200,"column":18},"end":{"line":200,"column":23}},"line":200},"23":{"name":"(anonymous_23)","decl":{"start":{"line":204,"column":27},"end":{"line":204,"column":28}},"loc":{"start":{"line":205,"column":3},"end":{"line":207,"column":44}},"line":205},"24":{"name":"(anonymous_24)","decl":{"start":{"line":207,"column":10},"end":{"line":207,"column":11}},"loc":{"start":{"line":207,"column":20},"end":{"line":207,"column":43}},"line":207},"25":{"name":"(anonymous_25)","decl":{"start":{"line":211,"column":1},"end":{"line":211,"column":2}},"loc":{"start":{"line":211,"column":9},"end":{"line":223,"column":2}},"line":211},"26":{"name":"(anonymous_26)","decl":{"start":{"line":213,"column":28},"end":{"line":213,"column":29}},"loc":{"start":{"line":213,"column":38},"end":{"line":213,"column":80}},"line":213},"27":{"name":"(anonymous_27)","decl":{"start":{"line":213,"column":64},"end":{"line":213,"column":65}},"loc":{"start":{"line":213,"column":70},"end":{"line":213,"column":79}},"line":213},"28":{"name":"(anonymous_28)","decl":{"start":{"line":216,"column":27},"end":{"line":216,"column":28}},"loc":{"start":{"line":217,"column":3},"end":{"line":221,"column":26}},"line":217},"29":{"name":"(anonymous_29)","decl":{"start":{"line":221,"column":10},"end":{"line":221,"column":11}},"loc":{"start":{"line":221,"column":16},"end":{"line":221,"column":25}},"line":221},"30":{"name":"(anonymous_30)","decl":{"start":{"line":225,"column":1},"end":{"line":225,"column":2}},"loc":{"start":{"line":225,"column":16},"end":{"line":243,"column":2}},"line":225},"31":{"name":"(anonymous_31)","decl":{"start":{"line":230,"column":27},"end":{"line":230,"column":28}},"loc":{"start":{"line":230,"column":37},"end":{"line":242,"column":3}},"line":230},"32":{"name":"(anonymous_32)","decl":{"start":{"line":241,"column":10},"end":{"line":241,"column":11}},"loc":{"start":{"line":241,"column":26},"end":{"line":241,"column":112}},"line":241},"33":{"name":"(anonymous_33)","decl":{"start":{"line":241,"column":55},"end":{"line":241,"column":56}},"loc":{"start":{"line":241,"column":63},"end":{"line":241,"column":93}},"line":241},"34":{"name":"(anonymous_34)","decl":{"start":{"line":241,"column":101},"end":{"line":241,"column":102}},"loc":{"start":{"line":241,"column":107},"end":{"line":241,"column":111}},"line":241},"35":{"name":"(anonymous_35)","decl":{"start":{"line":245,"column":1},"end":{"line":245,"column":2}},"loc":{"start":{"line":245,"column":25},"end":{"line":263,"column":2}},"line":245},"36":{"name":"(anonymous_36)","decl":{"start":{"line":250,"column":27},"end":{"line":250,"column":28}},"loc":{"start":{"line":250,"column":37},"end":{"line":262,"column":3}},"line":250},"37":{"name":"(anonymous_37)","decl":{"start":{"line":261,"column":10},"end":{"line":261,"column":11}},"loc":{"start":{"line":261,"column":31},"end":{"line":261,"column":122}},"line":261},"38":{"name":"(anonymous_38)","decl":{"start":{"line":261,"column":65},"end":{"line":261,"column":66}},"loc":{"start":{"line":261,"column":73},"end":{"line":261,"column":103}},"line":261},"39":{"name":"(anonymous_39)","decl":{"start":{"line":261,"column":111},"end":{"line":261,"column":112}},"loc":{"start":{"line":261,"column":117},"end":{"line":261,"column":121}},"line":261}},"branchMap":{"0":{"loc":{"start":{"line":14,"column":8},"end":{"line":14,"column":17}},"type":"binary-expr","locations":[{"start":{"line":14,"column":8},"end":{"line":14,"column":11}},{"start":{"line":14,"column":15},"end":{"line":14,"column":17}}],"line":14},"1":{"loc":{"start":{"line":15,"column":2},"end":{"line":17,"column":3}},"type":"if","locations":[{"start":{"line":15,"column":2},"end":{"line":17,"column":3}},{"start":{"line":15,"column":2},"end":{"line":17,"column":3}}],"line":15},"2":{"loc":{"start":{"line":19,"column":2},"end":{"line":21,"column":3}},"type":"if","locations":[{"start":{"line":19,"column":2},"end":{"line":21,"column":3}},{"start":{"line":19,"column":2},"end":{"line":21,"column":3}}],"line":19},"3":{"loc":{"start":{"line":48,"column":5},"end":{"line":50,"column":6}},"type":"if","locations":[{"start":{"line":48,"column":5},"end":{"line":50,"column":6}},{"start":{"line":48,"column":5},"end":{"line":50,"column":6}}],"line":48},"4":{"loc":{"start":{"line":53,"column":5},"end":{"line":113,"column":6}},"type":"if","locations":[{"start":{"line":53,"column":5},"end":{"line":113,"column":6}},{"start":{"line":53,"column":5},"end":{"line":113,"column":6}}],"line":53},"5":{"loc":{"start":{"line":55,"column":23},"end":{"line":55,"column":60}},"type":"binary-expr","locations":[{"start":{"line":55,"column":23},"end":{"line":55,"column":47}},{"start":{"line":55,"column":51},"end":{"line":55,"column":60}}],"line":55},"6":{"loc":{"start":{"line":119,"column":2},"end":{"line":144,"column":3}},"type":"if","locations":[{"start":{"line":119,"column":2},"end":{"line":144,"column":3}},{"start":{"line":119,"column":2},"end":{"line":144,"column":3}}],"line":119},"7":{"loc":{"start":{"line":148,"column":4},"end":{"line":150,"column":5}},"type":"if","locations":[{"start":{"line":148,"column":4},"end":{"line":150,"column":5}},{"start":{"line":148,"column":4},"end":{"line":150,"column":5}}],"line":148},"8":{"loc":{"start":{"line":158,"column":20},"end":{"line":158,"column":79}},"type":"cond-expr","locations":[{"start":{"line":158,"column":46},"end":{"line":158,"column":72}},{"start":{"line":158,"column":75},"end":{"line":158,"column":79}}],"line":158},"9":{"loc":{"start":{"line":160,"column":2},"end":{"line":176,"column":3}},"type":"if","locations":[{"start":{"line":160,"column":2},"end":{"line":176,"column":3}},{"start":{"line":160,"column":2},"end":{"line":176,"column":3}}],"line":160},"10":{"loc":{"start":{"line":188,"column":2},"end":{"line":190,"column":3}},"type":"if","locations":[{"start":{"line":188,"column":2},"end":{"line":190,"column":3}},{"start":{"line":188,"column":2},"end":{"line":190,"column":3}}],"line":188},"11":{"loc":{"start":{"line":192,"column":2},"end":{"line":202,"column":3}},"type":"if","locations":[{"start":{"line":192,"column":2},"end":{"line":202,"column":3}},{"start":{"line":192,"column":2},"end":{"line":202,"column":3}}],"line":192},"12":{"loc":{"start":{"line":212,"column":2},"end":{"line":214,"column":3}},"type":"if","locations":[{"start":{"line":212,"column":2},"end":{"line":214,"column":3}},{"start":{"line":212,"column":2},"end":{"line":214,"column":3}}],"line":212},"13":{"loc":{"start":{"line":226,"column":2},"end":{"line":228,"column":3}},"type":"if","locations":[{"start":{"line":226,"column":2},"end":{"line":228,"column":3}},{"start":{"line":226,"column":2},"end":{"line":228,"column":3}}],"line":226},"14":{"loc":{"start":{"line":246,"column":2},"end":{"line":248,"column":3}},"type":"if","locations":[{"start":{"line":246,"column":2},"end":{"line":248,"column":3}},{"start":{"line":246,"column":2},"end":{"line":248,"column":3}}],"line":246}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":0,"11":1,"12":1,"13":1,"14":1,"15":9,"16":1,"17":9,"18":1,"19":1,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":1,"83":0,"84":0,"85":0,"86":1,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":1},"f":{"0":1,"1":9,"2":9,"3":1,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":1,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0},"b":{"0":[1,0],"1":[0,1],"2":[1,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,1],"13":[0,0],"14":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"ffbed58573fdb70302f2fa5eca63feeee182cc4f","contentHash":"957ac5d6ce8026345907664940444261249abfcba91db614178eece09bbfb910"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"6cdae809-9b2c-44f0-b9c2-41555a0e2af9","pid":99259,"argv":["/Users/jaredwray/.nvm/versions/node/v16.13.1/bin/node","/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/node_modules/ava/lib/worker/base.js"],"execArgv":["--enable-source-maps"],"cwd":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo","time":1643222020427,"ppid":99258,"coverageFilename":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/.nyc_output/216ebf05-ecde-4f49-891b-59762203bcc0.json","externalId":"","uuid":"216ebf05-ecde-4f49-891b-59762203bcc0","files":["/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/src/index.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":null,"pid":99259,"argv":["/Users/jaredwray/.nvm/versions/node/v16.13.1/bin/node","/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/node_modules/.bin/ava"],"execArgv":[],"cwd":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo","time":1643222020176,"ppid":99258,"coverageFilename":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/.nyc_output/6cdae809-9b2c-44f0-b9c2-41555a0e2af9.json","externalId":"","uuid":"6cdae809-9b2c-44f0-b9c2-41555a0e2af9","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"processes":{"216ebf05-ecde-4f49-891b-59762203bcc0":{"parent":"6cdae809-9b2c-44f0-b9c2-41555a0e2af9","children":[]},"6cdae809-9b2c-44f0-b9c2-41555a0e2af9":{"parent":null,"children":["216ebf05-ecde-4f49-891b-59762203bcc0"]}},"files":{"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/mongo/src/index.js":["216ebf05-ecde-4f49-891b-59762203bcc0"]},"externalIds":{}}
|
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# @keyv/mongo [<img width="100" align="right" src="https://
|
|
1
|
+
# @keyv/mongo [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/jaredwra/keyv)
|
|
2
2
|
|
|
3
3
|
> MongoDB storage adapter for Keyv
|
|
4
4
|
|
|
5
|
-
[](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
|
|
6
|
+
[](https://codecov.io/gh/jaredwray/keyv)
|
|
7
7
|
[](https://www.npmjs.com/package/@keyv/mongo)
|
|
8
8
|
|
|
9
9
|
MongoDB storage adapter for [Keyv](https://github.com/jaredwray/keyv).
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
2
|
+
"name": "@keyv/mongo",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "MongoDB storage adapter for Keyv",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "xo && nyc ava",
|
|
8
|
+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
|
9
|
+
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov"
|
|
10
|
+
},
|
|
11
|
+
"xo": {
|
|
12
|
+
"extends": "xo-lukechilds",
|
|
13
|
+
"rules": {
|
|
14
|
+
"unicorn/prefer-module": 0,
|
|
15
|
+
"unicorn/no-array-reduce": 0,
|
|
16
|
+
"unicorn/prefer-object-from-entries": 0
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"ava": {
|
|
20
|
+
"require": [
|
|
21
|
+
"requirable"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"mongo",
|
|
30
|
+
"mongodb",
|
|
31
|
+
"keyv",
|
|
32
|
+
"storage",
|
|
33
|
+
"adapter",
|
|
34
|
+
"key",
|
|
35
|
+
"value",
|
|
36
|
+
"store",
|
|
37
|
+
"cache",
|
|
38
|
+
"ttl"
|
|
39
|
+
],
|
|
40
|
+
"author": "Jared Wray <me@jaredwray.com> (https://jaredwray.com)",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/jaredwray/keyv/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/jaredwray/keyv",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"mongodb": "^4.3.1",
|
|
48
|
+
"pify": "^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@keyv/test-suite": "*",
|
|
52
|
+
"ava": "^3.15.0",
|
|
53
|
+
"eslint-config-xo-lukechilds": "^1.0.1",
|
|
54
|
+
"keyv": "*",
|
|
55
|
+
"nyc": "^15.1.0",
|
|
56
|
+
"requirable": "^1.0.5",
|
|
57
|
+
"this": "^1.1.0",
|
|
58
|
+
"xo": "^0.47.0"
|
|
59
|
+
}
|
|
60
60
|
}
|
package/src/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const EventEmitter = require('events');
|
|
4
|
-
const
|
|
4
|
+
const Buffer = require('buffer').Buffer;
|
|
5
|
+
const mongoClient = require('mongodb').MongoClient;
|
|
6
|
+
const GridFSBucket = require('mongodb').GridFSBucket;
|
|
5
7
|
const pify = require('pify');
|
|
6
8
|
|
|
9
|
+
const keyvMongoKeys = new Set(['url', 'collection', 'namespace', 'serialize', 'deserialize', 'uri', 'useGridFS']);
|
|
7
10
|
class KeyvMongo extends EventEmitter {
|
|
8
11
|
constructor(url, options) {
|
|
9
12
|
super();
|
|
@@ -17,43 +20,168 @@ class KeyvMongo extends EventEmitter {
|
|
|
17
20
|
url = Object.assign({ url: url.uri }, url);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
this.opts = Object.assign(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
this.opts = Object.assign(
|
|
24
|
+
{
|
|
25
|
+
url: 'mongodb://127.0.0.1:27017',
|
|
26
|
+
collection: 'keyv',
|
|
27
|
+
},
|
|
28
|
+
url,
|
|
29
|
+
options,
|
|
30
|
+
);
|
|
25
31
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const mongoOptions = Object.fromEntries(
|
|
33
|
+
Object.entries(this.opts).filter(
|
|
34
|
+
([k]) => !keyvMongoKeys.has(k),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
this.opts = Object.fromEntries(
|
|
39
|
+
Object.entries(this.opts).filter(
|
|
40
|
+
([k]) => keyvMongoKeys.has(k),
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Implementation from sql by lukechilds,
|
|
45
|
+
this.connect = new Promise(resolve => {
|
|
46
|
+
mongoClient.connect(this.opts.url, mongoOptions
|
|
47
|
+
, (error, client) => {
|
|
48
|
+
if (error) {
|
|
49
|
+
return this.emit('error', error);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.db = client.db(this.opts.db);
|
|
53
|
+
if (this.opts.useGridFS) {
|
|
54
|
+
this.bucket = new GridFSBucket(this.db, {
|
|
55
|
+
readPreference: this.opts.readPreference || 'primary',
|
|
56
|
+
bucketName: this.opts.collection,
|
|
57
|
+
});
|
|
58
|
+
this.store = this.db.collection(this.opts.collection + '.files');
|
|
59
|
+
this.store.createIndex({
|
|
60
|
+
filename: 'hashed',
|
|
61
|
+
});
|
|
62
|
+
this.store.createIndex({
|
|
63
|
+
uploadDate: -1,
|
|
64
|
+
});
|
|
65
|
+
this.store.createIndex({
|
|
66
|
+
'metadata.expiresAt': 1,
|
|
67
|
+
});
|
|
68
|
+
this.store.createIndex({
|
|
69
|
+
'metadata.lastAccessed': 1,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
for (const method of [
|
|
73
|
+
'updateOne',
|
|
74
|
+
]) {
|
|
75
|
+
this.store[method] = pify(this.store[method].bind(this.store));
|
|
76
|
+
}
|
|
39
77
|
|
|
40
|
-
|
|
78
|
+
for (const method of [
|
|
79
|
+
'find',
|
|
80
|
+
'drop',
|
|
81
|
+
]) {
|
|
82
|
+
this.bucket[method] = pify(this.bucket[method].bind(this.bucket));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
resolve({ bucket: this.bucket, store: this.store, db: this.db });
|
|
86
|
+
} else {
|
|
87
|
+
this.store = this.db.collection(this.opts.collection);
|
|
88
|
+
this.store.createIndex(
|
|
89
|
+
{ key: 1 },
|
|
90
|
+
{
|
|
91
|
+
unique: true,
|
|
92
|
+
background: true,
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
this.store.createIndex(
|
|
96
|
+
{ expiresAt: 1 },
|
|
97
|
+
{
|
|
98
|
+
expireAfterSeconds: 0,
|
|
99
|
+
background: true,
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
for (const method of [
|
|
104
|
+
'updateOne',
|
|
105
|
+
'findOne',
|
|
106
|
+
'deleteOne',
|
|
107
|
+
'deleteMany',
|
|
108
|
+
]) {
|
|
109
|
+
this.store[method] = pify(this.store[method].bind(this.store));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resolve(this.store);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
41
116
|
}
|
|
42
117
|
|
|
43
118
|
get(key) {
|
|
44
|
-
|
|
45
|
-
.then(
|
|
46
|
-
|
|
119
|
+
if (this.opts.useGridFS) {
|
|
120
|
+
return this.connect.then(client => {
|
|
121
|
+
client.store.updateOne({
|
|
122
|
+
filename: key,
|
|
123
|
+
}, {
|
|
124
|
+
$set: {
|
|
125
|
+
'metadata.lastAccessed': new Date(),
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const stream = client.bucket.openDownloadStreamByName(key);
|
|
130
|
+
return new Promise(resolve => {
|
|
131
|
+
let resp = [];
|
|
132
|
+
stream.on('error', () => resolve());
|
|
133
|
+
|
|
134
|
+
stream.on('end', () => {
|
|
135
|
+
resp = Buffer.concat(resp).toString('utf-8');
|
|
136
|
+
resolve(resp);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
stream.on('data', chunk => {
|
|
140
|
+
resp.push(chunk);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return this.connect.then(store =>
|
|
147
|
+
store.findOne({ key: { $eq: key } }).then(doc => {
|
|
148
|
+
if (!doc) {
|
|
47
149
|
return undefined;
|
|
48
150
|
}
|
|
49
151
|
|
|
50
152
|
return doc.value;
|
|
51
|
-
})
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
52
155
|
}
|
|
53
156
|
|
|
54
157
|
set(key, value, ttl) {
|
|
55
|
-
const expiresAt =
|
|
56
|
-
|
|
158
|
+
const expiresAt = typeof ttl === 'number' ? new Date(Date.now() + ttl) : null;
|
|
159
|
+
|
|
160
|
+
if (this.opts.useGridFS) {
|
|
161
|
+
return this.connect.then(client => {
|
|
162
|
+
const stream = client.bucket.openUploadStream(key, {
|
|
163
|
+
metadata: {
|
|
164
|
+
expiresAt,
|
|
165
|
+
lastAccessed: new Date(),
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return new Promise(resolve => {
|
|
170
|
+
stream.on('finish', () => {
|
|
171
|
+
resolve(stream);
|
|
172
|
+
});
|
|
173
|
+
stream.end(value);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return this.connect.then(store =>
|
|
179
|
+
store.updateOne(
|
|
180
|
+
{ key: { $eq: key } },
|
|
181
|
+
{ $set: { key, value, expiresAt } },
|
|
182
|
+
{ upsert: true },
|
|
183
|
+
),
|
|
184
|
+
);
|
|
57
185
|
}
|
|
58
186
|
|
|
59
187
|
delete(key) {
|
|
@@ -61,13 +189,77 @@ class KeyvMongo extends EventEmitter {
|
|
|
61
189
|
return Promise.resolve(false);
|
|
62
190
|
}
|
|
63
191
|
|
|
64
|
-
|
|
65
|
-
.then(
|
|
192
|
+
if (this.opts.useGridFS) {
|
|
193
|
+
return this.connect.then(client => {
|
|
194
|
+
const connection = client.db;
|
|
195
|
+
const bucket = new GridFSBucket(connection, {
|
|
196
|
+
bucketName: this.opts.collection,
|
|
197
|
+
});
|
|
198
|
+
return bucket.find({ filename: key }).toArray()
|
|
199
|
+
.then(files => client.bucket.delete(files[0]._id).then(() => true))
|
|
200
|
+
.catch(() => false);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return this.connect.then(store =>
|
|
205
|
+
store
|
|
206
|
+
.deleteOne({ key: { $eq: key } })
|
|
207
|
+
.then(object => object.deletedCount > 0),
|
|
208
|
+
);
|
|
66
209
|
}
|
|
67
210
|
|
|
68
211
|
clear() {
|
|
69
|
-
|
|
70
|
-
.then(() => undefined);
|
|
212
|
+
if (this.opts.useGridFS) {
|
|
213
|
+
return this.connect.then(client => client.bucket.drop().then(() => undefined));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return this.connect.then(store =>
|
|
217
|
+
store
|
|
218
|
+
.deleteMany({
|
|
219
|
+
key: new RegExp(`^${this.namespace}:`),
|
|
220
|
+
})
|
|
221
|
+
.then(() => undefined),
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
clearExpired() {
|
|
226
|
+
if (!this.opts.useGridFS) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return this.connect.then(client => {
|
|
231
|
+
const connection = client.db;
|
|
232
|
+
const bucket = new GridFSBucket(connection, {
|
|
233
|
+
bucketName: this.opts.collection,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return bucket.find({
|
|
237
|
+
'metadata.expiresAt': {
|
|
238
|
+
$lte: new Date(Date.now()),
|
|
239
|
+
},
|
|
240
|
+
}).toArray()
|
|
241
|
+
.then(expiredFiles => Promise.all(expiredFiles.map(file => client.bucket.delete(file._id))).then(() => true));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
clearUnusedFor(seconds) {
|
|
246
|
+
if (!this.opts.useGridFS) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this.connect.then(client => {
|
|
251
|
+
const connection = client.db;
|
|
252
|
+
const bucket = new GridFSBucket(connection, {
|
|
253
|
+
bucketName: this.opts.collection,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
return bucket.find({
|
|
257
|
+
'metadata.lastAccessed': {
|
|
258
|
+
$lte: new Date(Date.now() - (seconds * 1000)),
|
|
259
|
+
},
|
|
260
|
+
}).toArray()
|
|
261
|
+
.then(lastAccessedFiles => Promise.all(lastAccessedFiles.map(file => client.bucket.delete(file._id))).then(() => true));
|
|
262
|
+
});
|
|
71
263
|
}
|
|
72
264
|
}
|
|
73
265
|
|
package/test/test.js
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
const test = require('ava');
|
|
2
2
|
const keyvTestSuite = require('@keyv/test-suite').default;
|
|
3
|
-
const { keyvOfficialTests } = require('@keyv/test-suite');
|
|
4
3
|
const Keyv = require('keyv');
|
|
5
4
|
const KeyvMongo = require('this');
|
|
5
|
+
const { keyvOfficialTests } = require('@keyv/test-suite');
|
|
6
|
+
|
|
7
|
+
const options = { useNewUrlParser: true, useUnifiedTopology: true, serverSelectionTimeoutMS: 5000 };
|
|
6
8
|
|
|
7
9
|
const mongoURL = 'mongodb://127.0.0.1:27017';
|
|
8
10
|
|
|
9
|
-
keyvOfficialTests(test, Keyv, mongoURL, 'mongodb://
|
|
11
|
+
keyvOfficialTests(test, Keyv, mongoURL, 'mongodb://foo', options);
|
|
10
12
|
|
|
11
|
-
const store = () => new KeyvMongo(mongoURL);
|
|
13
|
+
const store = () => new KeyvMongo(mongoURL, options);
|
|
12
14
|
keyvTestSuite(test, Keyv, store);
|
|
13
15
|
|
|
14
16
|
test('default options', t => {
|
|
15
17
|
const store = new KeyvMongo();
|
|
16
18
|
t.deepEqual(store.opts, {
|
|
17
|
-
url:
|
|
19
|
+
url: mongoURL,
|
|
18
20
|
collection: 'keyv',
|
|
19
21
|
});
|
|
20
22
|
});
|
|
21
23
|
|
|
24
|
+
test('default options with url.uri', t => {
|
|
25
|
+
const store = new KeyvMongo({ uri: mongoURL });
|
|
26
|
+
t.is(store.opts.uri, mongoURL);
|
|
27
|
+
t.is(store.opts.url, mongoURL);
|
|
28
|
+
});
|
|
29
|
+
|
|
22
30
|
test('Collection option merges into default options', t => {
|
|
23
31
|
const store = new KeyvMongo({ collection: 'foo' });
|
|
24
32
|
t.deepEqual(store.opts, {
|
|
25
|
-
url:
|
|
33
|
+
url: mongoURL,
|
|
34
|
+
collection: 'foo',
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('useGridFS option merges into default options', t => {
|
|
39
|
+
const store = new KeyvMongo({ useGridFS: true, collection: 'foo' });
|
|
40
|
+
t.deepEqual(store.opts, {
|
|
41
|
+
url: mongoURL,
|
|
42
|
+
useGridFS: true,
|
|
26
43
|
collection: 'foo',
|
|
27
44
|
});
|
|
28
45
|
});
|
|
@@ -36,6 +53,107 @@ test('Collection option merges into default options if URL is passed', t => {
|
|
|
36
53
|
});
|
|
37
54
|
|
|
38
55
|
test('.delete() with no args doesn\'t empty the collection', async t => {
|
|
39
|
-
const store = new KeyvMongo('foo'); // Make sure we don't actually connect
|
|
56
|
+
const store = new KeyvMongo('mongodb://foo'); // Make sure we don't actually connect
|
|
40
57
|
t.false(await store.delete());
|
|
41
58
|
});
|
|
59
|
+
|
|
60
|
+
test('.delete() with key as number', async t => {
|
|
61
|
+
const store = new KeyvMongo(mongoURL, { collection: 'foo' });
|
|
62
|
+
t.false(await store.delete(123));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test.serial('Stores value in GridFS', async t => {
|
|
66
|
+
const store = new KeyvMongo(Object.assign({
|
|
67
|
+
useGridFS: true,
|
|
68
|
+
}, options));
|
|
69
|
+
const result = await store.set('key1', 'keyv1', 0);
|
|
70
|
+
const get = await store.get('key1');
|
|
71
|
+
t.is(result.filename, 'key1');
|
|
72
|
+
t.is(get, 'keyv1');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test.serial('Gets value from GridFS', async t => {
|
|
76
|
+
const store = new KeyvMongo(Object.assign({
|
|
77
|
+
useGridFS: true,
|
|
78
|
+
}, options));
|
|
79
|
+
const result = await store.get('key1');
|
|
80
|
+
t.is(result, 'keyv1');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test.serial('Deletes value from GridFS', async t => {
|
|
84
|
+
const store = new KeyvMongo(Object.assign({
|
|
85
|
+
useGridFS: true,
|
|
86
|
+
}, options));
|
|
87
|
+
const result = await store.delete('key1');
|
|
88
|
+
t.is(result, true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test.serial('Deletes non existent value from GridFS', async t => {
|
|
92
|
+
const store = new KeyvMongo(Object.assign({
|
|
93
|
+
useGridFS: true,
|
|
94
|
+
}, options));
|
|
95
|
+
const result = await store.delete('no-existent-value');
|
|
96
|
+
t.is(result, false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test.serial('Stores value with TTL in GridFS', async t => {
|
|
100
|
+
const store = new KeyvMongo(Object.assign({
|
|
101
|
+
useGridFS: true,
|
|
102
|
+
}, options));
|
|
103
|
+
const result = await store.set('key1', 'keyv1', 0);
|
|
104
|
+
t.is(result.filename, 'key1');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test.serial('Clears expired value from GridFS', async t => {
|
|
108
|
+
const store = new KeyvMongo(Object.assign({
|
|
109
|
+
useGridFS: true,
|
|
110
|
+
}, options));
|
|
111
|
+
const cleared = await store.clearExpired();
|
|
112
|
+
t.is(cleared, true);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test.serial('Clears unused files from GridFS', async t => {
|
|
116
|
+
const store = new KeyvMongo(Object.assign({
|
|
117
|
+
useGridFS: true,
|
|
118
|
+
}, options));
|
|
119
|
+
const cleared = await store.clearUnusedFor(5);
|
|
120
|
+
t.is(cleared, true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test.serial('Clears expired value only when GridFS options is true', async t => {
|
|
124
|
+
const store = new KeyvMongo(Object.assign(options));
|
|
125
|
+
const cleared = await store.clearExpired();
|
|
126
|
+
t.is(cleared, false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test.serial('Clears unused files only when GridFS options is true', async t => {
|
|
130
|
+
const store = new KeyvMongo(Object.assign(options));
|
|
131
|
+
const cleared = await store.clearUnusedFor(5);
|
|
132
|
+
t.is(cleared, false);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test.serial('Gets non-existent file and return should be undefined', async t => {
|
|
136
|
+
const store = new KeyvMongo(Object.assign({
|
|
137
|
+
useGridFS: true,
|
|
138
|
+
}, options));
|
|
139
|
+
const result = await store.get('non-existent-file');
|
|
140
|
+
t.is(typeof result, 'undefined');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test.serial('Non-string keys are not permitted in delete', async t => {
|
|
144
|
+
const store = new KeyvMongo(Object.assign({
|
|
145
|
+
useGridFS: true,
|
|
146
|
+
}, options));
|
|
147
|
+
const result = await store.delete({
|
|
148
|
+
ok: true,
|
|
149
|
+
});
|
|
150
|
+
t.is(result, false);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test.serial('Clears entire cache store', async t => {
|
|
154
|
+
const store = new KeyvMongo(Object.assign({
|
|
155
|
+
useGridFS: true,
|
|
156
|
+
}, options));
|
|
157
|
+
const result = await store.clear();
|
|
158
|
+
t.is(typeof result, 'undefined');
|
|
159
|
+
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: build
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ master ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ master ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
strategy:
|
|
13
|
-
matrix:
|
|
14
|
-
node: [ '12', '14', '16' ]
|
|
15
|
-
mongodb-version: [ '4.4', '5.0']
|
|
16
|
-
name: Node ${{ matrix.node }}
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v2
|
|
19
|
-
- name: Setup node
|
|
20
|
-
uses: actions/setup-node@v2
|
|
21
|
-
with:
|
|
22
|
-
node-version: ${{ matrix.node }}
|
|
23
|
-
|
|
24
|
-
- name: Start MongoDB
|
|
25
|
-
uses: supercharge/mongodb-github-action@1.6.0
|
|
26
|
-
with:
|
|
27
|
-
mongodb-version: ${{ matrix.mongodb-version }}
|
|
28
|
-
|
|
29
|
-
- run: npm install
|
|
30
|
-
- run: npm test
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017-2021 Jared Wray & Luke Childs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|