forked from strongloop/loopback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory.test.js
45 lines (37 loc) · 1.11 KB
/
memory.test.js
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
// Copyright IBM Corp. 2013,2018. All Rights Reserved.
// Node module: loopback
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
const assert = require('assert');
const loopback = require('../');
describe('Memory Connector', function() {
it('Create a model using the memory connector', function(done) {
// use the built in memory function
// to create a memory data source
let memory = loopback.memory();
// or create it using the standard
// data source creation api
memory = loopback.createDataSource({
connector: loopback.Memory,
});
// create a model using the
// memory data source
const properties = {
name: String,
price: Number,
};
const Product = memory.createModel('product', properties);
Product.create([
{name: 'apple', price: 0.79},
{name: 'pear', price: 1.29},
{name: 'orange', price: 0.59},
], count);
function count() {
Product.count(function(err, count) {
assert.equal(count, 3);
done();
});
}
});
});