Code Monkey home page Code Monkey logo

node-odata's People

Contributors

adrfrank avatar afska avatar andriy-f avatar cloudyafternoon avatar garethf89 avatar marcbachmann avatar qknow-w avatar r1mar avatar vincent178 avatar zackyang000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-odata's Issues

'maxTop' not work.

odata.set('maxTop', 10)

and

odata.register({options: {maxTop: 10}})

Both not work.

API should be simplified.

odata.resource.register(params) 
-> 
odata.resource(params)
odata.function.register(params) 
->
odata.get(params) 
odata.put(params) 
odata.del(params) 
odata.post(params) 

Update with PUT not working

I have quite a complex model:

server.resource('subscriptionConfigurations', { 
    user: String,
    topics: [{
        name : String,
        situationDescriptions : [{
            criteria : {
                stocks : {
                    enabled : Boolean,
                    exchange : String,
                    stockChangeAmount : Number,
                    stockChangeDirection : String,
                    stockChangeUnit : String,
                    symbol : String
                },
                tweets : {
                    enabled : Boolean,
                    hashtags : Array,
                    keywords : Array,
                    operator : String,
                    tweetNumber : Number,
                    tweetOperator : String,
                    users : Array
                },
                periodNumber : Number,
                periodUnit : String
            }
        }]

    }]
});

Here, updating a document with PUT fails. The response of the PUT returns exactly what I have put into the request payload, however when I do a get on the document or get all documents, the document that should have been updated is still in the old version.

I only can circumvent this by deleting the document and POSTing it again. Can you please look at it?

put before method

put().before(function(entity){
entity.name='test';
})
执行后数据库中的name没有变化

version:0.7.4

MySQL

Is there a mysql example?

Live Demo links not working

The live demo links http://books.zackyang.com/book on the README.md are not working. They deliver the following error:

502 Bad Gateway
nginx/1.4.6 (Ubuntu)

Cannot find module './Resource'

在阿里云服务器上安装node-odata模块时,报错
module.js:341
throw err;
^

Error: Cannot find module './Resource'
在这个环境下测试了express,运行没有问题

请问如何实现下一页的功能?

比如直接 get /books 会得到所有的 books,但是有时候如果 book 太多的话(比如有几万本)一个 json
明显太大了,可以直接通过 $top=10 返回前 10 本书。但是我想不通过这个 top 查询,而是直接类似
这样 http://services.odata.org/V2/Northwind/Northwind.svc/Customers?%24format=JSON 有一个 "__next" 属性,这样就可以得到下面 20 个人的信息了,主要是比较方便前端处理。请问这样的 "__next" 功能如何通过 node-odata 实现呢?

Support fluent API to register resource and function.

Example:

odata
.all()
  .auth(function(){...})
.delete()
  .before(function(){...})
.resource
  .create()
  .url('/book')
  .model(model)
  .all()
    .auth(function(){...})
  .get()
    .after(function(){...})
  .delete()
    .before(function(){...})
  .post()
    .action('50-off')
      .handle(function(){...})
  .options()
    .orderby('date desc')

Logical operators 'and' and 'or' is incorrect in $filter.

1. 'or' is not work

http://localhost:3000/book?$filter=price gt 30 or price lt 30

is same as

http://localhost:3000/book?$filter=price gt 30 and price lt 30

This is a mistake. It's should return something when use 'or' to query.

2. 'and' is not correct when $filter same field

http://localhost:3000/book?$filter=price eq 44.95 and price eq 36.95

This query will return 2 result both include 44.95 and 36.95.

The internal ID _id is not returned

When I query for objects, the internal ID of the MongoDB document is not returned.

Request: http://localhost:3000/subscriptionConfigurations
Response-Body: 
{
  "value": [
    {
      "id": "2016-04-28T13:19:09.907Z",
      "text": "foo bar 32"
    }
  ]
}

However: in the DB, the object has the internal id _id : d30b54e9-12a2-49ba-8da0-87b3c1500aab

I can also request it directly:

Request: http://localhost:3000/subscriptionConfigurations(d30b54e9-12a2-49ba-8da0-87b3c1500aab)
Response: 
{
  "id": "2016-04-28T13:19:09.907Z",
  "text": "foo bar 32"
}

In my server code, I use:

server.resource('subscriptionConfigurations', { 
    _id: String,
    id: Date, 
    text: String 
});

Why is _id not returned?

When I try in the server code

server.resource('subscriptionConfigurations', { 
    _id: require('mongoose').Schema.ObjectId,
    id: Date, 
    text: String 
});

... I get this error message:
Cast to ObjectId failed for value "d30b54e9-12a2-49ba-8da0-87b3c1500aab" at path "_id"

I'm using MongoDB version 3.0.11

CROS 的问题

您好,最近我在使用你的 node-odata 提供 API,ember.js 做前端,碰到了 cros 的问题,
于是我上 SO 提了一个问题:http://stackoverflow.com/questions/30147362/access-control-allow-origin-error-when-using-ember-jswith-ember-cli

回答者说不是 ember 的问题,需要在 服务器端 3000 端口激活 CORS,并给出了链接 http://enable-cors.org/server_expressjs.html

对于 express 我不是很熟,请问在使用 node-odata 的时候如何激活这个 CORS 呢?

非常感谢!

Status of this repo ?

Are you guys still working on this ? What about future updates and some production ready version ?

Support for null values?

I would like to query: ?$filter=bran_ eq null.
This is supported? or is there any way to do the same?

Thanks!

examples目录里的complex例程如何增删查?

我post的时候按照schema格式 制作body 如下:
{
custom: {
id: "1",
name: "john"
},
orderItems: [{
quantity: 10,
product: {
id: "1",
name: "com",
price: 2.1
}
}]
}

但是返回错误:
SyntaxError: Unexpected token c
   at Object.parse (native)
   at parse (/home/wxd/node/test-odata/node_modules/body-parser/lib/types/json.js:88:17)
   at /home/wxd/node/test-odata/node_modules/body-parser/lib/read.js:108:18
   at invokeCallback (/home/wxd/node/test-odata/node_modules/raw-body/index.js:262:16)
   at done (/home/wxd/node/test-odata/node_modules/raw-body/index.js:251:7)
   at IncomingMessage.onEnd (/home/wxd/node/test-odata/node_modules/raw-body/index.js:308:7)
   at emitNone (events.js:67:13)
   at IncomingMessage.emit (events.js:166:7)
   at endReadableNT (_stream_readable.js:913:12)
   at nextTickCallbackWith2Args (node.js:442:9)
   at process._tickCallback (node.js:356:17)

config _options[db]

直接配置数据库不可用。
如果不调用set方法,则无法连接db,因为没有调用mongoose.connect(value)
see config.coffee.

GET/books(:id)为什么不能用了?

作者你好,我用这个API查找对应ID的资源怎么总是返回404呢?我确定数据库里面有对应资源。不同的ID值查询总是返回相同的结果,DELETE以ID值为查询也是404

suggestion: add mongooseModel parameter on resources.register

Hi,
It would be useful to be able set a different mongooseModel when registering a new resource rather than use the url parameter as the name of the mongoDB collection:

server.resources.register({
    url: '/libri',
    mongooseModel: '/books',
    model: {
        title: String,
        price: Number
    }
});

this project looked great until... coffeescript

node-odata is currently at an alpha stage, it is stable but not 100% feature complete. node-odata is written by CoffeeScript then compiled to Javascript.

node-odata is written by CoffeeScript then compiled to Javascript.

CoffeeScript

why :(

Why using books/:id instead of books(:id)/?

Hi there,

first: Thank you for this great project. It looks promising.

But why are you using the books/:id url route instead the defined Odata way books(:id)? I also don't like this syntax that much, but it is set as the standard and your server should support it. Or what do you think?

greetings
Jan

reference to another document

hi

how can I reference the resource to another resource?
(reference document to another)

for example:
server.resource('books', {
title: String,
price: Number
});

server.resource('authors', {
name: String,
books: [ reference to book ]
});

I noticed that the _id is generated by type string and every time I use {type: String, ref: 'books'} the inserted data is {name: "foo", books: ["[object Object]"]}

is there a way to use reference?

thanks

before(req)

// 配置 POST /resource
.post().before(req)方法会执行2次before方法

Remove __v field in model.

The __v is:

The versionKey is a property set on each document when first created by Mongoose. This keys value contains the internal revision of the document. The name of this document property is configurable. The default is __v.

mongoose dependence should be remove.

$metadata missing

node-data is a pretty good tool. I was very happy to find it, then I have seen that you don't create standard $metadata.

I need to call the webservice from my OpenUI5 application, so I can't use it. What a pitty!

关于 cors 中间件的正确使用姿势

嗯目前我是直接改 node_modules/node-odata/lib/index.coffee 里的内容的,我把这个文件里面直接加上

cors = require('cors')
// ...此处省略一大段
app.use(cors())

虽然这样就能用了,但是当然我知道直接改这样不太好的。。

我在我的 index.js 尝试这样改:

 var cors = require('cors');
var odata = require('node-odata');

var server = odata('mongodb://localhost/odata_ember');

server.resources.register({
  url: '/articles',
  model: {
    title: String,
    content: String,
    category: String
  }
});

server.use(cors());
server.listen(3000);

当然这样是不行的,请问具体改怎样做呢?谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.